Tabs
Tabbed interface primitive with keyboard navigation.
Preview
A live, theme-aware example rendered with the published component.
Loading preview…
Import
Import the component from its dedicated entry point to keep the dependency and generated bundle explicit.
tsximport { Tabs } from "@tavojs/ui/tabs";Normal Tavo.js applications load component styles through the Tavo.js UI plugin. If the application manages component CSS manually, also import @tavojs/ui/css/tabs.
When to use
Use it when
Choose something else when
Examples
Tabs example
tsximport { Tabs } from "@tavojs/ui/tabs";
export function TabsExample1() {
const tabs = [
{ id: "overview", label: "Overview", content: "Project overview" },
{ id: "activity", label: "Activity", content: "Recent activity" }
];
const setTab = (_id: string) => undefined;
return (
<>
<Tabs tabs={tabs} activeId="overview" onChange={setTab} />
</>
);
}Common props and defaults
| 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 | Application controlled through activeId and the matching callback. |
| 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 |