Tabs
Tabbed interface primitive with keyboard navigation.
Preview
A live, theme-aware example rendered with the published component.
Loading preview…
Import
Import from the focused entry point below, or use the same named export from @tavojs/ui. Both are public APIs; measure the built application when comparing their bundle cost.
tsximport { Tabs } from "@tavojs/ui/tabs";The component import loads compiled component CSS. Enable tavoUi() for your project theme variables, or import @tavojs/ui/theme.css once for the package default theme. The equivalent CSS-safe component alias is @tavojs/ui/css/tabs.
When to use
Use it when
Choose something else when
Examples
These examples include imports and local state where interaction requires it. Render the exported component in a page after completing UI installation. Demo state stays in the mounted component; connect file handling, persistence, and data loading to your application as needed.
Tabs example
tsximport { createTavo } from "@tavojs/core";
import { Tabs } from "@tavojs/ui/tabs";
type State = { activeId: string };
export const TabsExample1 = createTavo<Record<string, never>, State>({
model: () => ({ activeId: "overview" }),
view: ({ state, model }) => (
<>
<Tabs
tabs={[
{ id: "overview", label: "Overview", content: "Project overview" },
{ id: "activity", label: "Activity", content: "Recent activity" }
]}
activeId={state.activeId}
onChange={(activeId) => model.set("activeId", activeId)}
/>
</>
)
});Common props and defaults
A curated starting point. The complete TypeScript API below includes additional props and compound member contracts.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Optional class hook applied to the public root element owned by the component. |
tabs | { id: string; label: Child; content?: Child }[] | Required | Configures tabs for this component. |
activeId | string | Required | Configures activeId for this component. |
onChange | (tabId: string) => void | — | Configures onChange for this component. |
idPrefix | string | — | Configures idPrefix for this component. |
orientation | "horizontal" | "vertical" | — | Configures orientation for this component. |
Complete TypeScript API
Import from @tavojs/ui/tabs. Published exports: TabItem, Tabs, TabsContent, TabsIndicator, TabsList, TabsProps, TabsRoot, TabsTrigger.
TabsProps
| Property | Type | Required | Description |
|---|---|---|---|
tabs | TabItem[] | Yes | Configures tabs for this component. |
activeId | string | Yes | Configures activeId for this component. |
children | Child | No | Inherited children attribute accepted by Tabs. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
onChange | (tabId: string) => void | No | Configures onChange for this component. |
idPrefix | string | No | Configures idPrefix for this component. |
orientation | "horizontal" | "vertical" | No | Configures orientation for this component. |
State ownership and DOM target
| Concern | Contract |
|---|---|
| State | Use activeId to supply rendered state. Update it through the documented callback or native event handler. |
| DOM target | Public passthrough props target the component root. Treat nested elements and private class names as implementation details. |
Anatomy and related components
Public compound members: Root, List, Trigger, Content, Indicator
Limitations
Avoid Tabs when replacing interactive controls with content-only components.
Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.
Accessibility
Uses tablist, tab, tabpanel roles and arrow/Home/End keyboard navigation.
Uses tablist, tab, tabpanel roles and arrow/Home/End keyboard navigation.
Component status
| Contract | Current value |
|---|---|
| Maturity | stable |
| Category | content |
| Component import | @tavojs/ui/tabs |
| Explicit CSS import | @tavojs/ui/css/tabs |
| Preview | Interactive preview available on this page |