Navigated to /docs/ui/components/tabs

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.

TSX
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

Use `Tabs` for tabbed content. Supports item-array mode and compound helpers

Choose something else when

Avoid Tabs when replacing interactive controls with content-only components.

Examples

Tabs example

TSX
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

PropTypeDefaultDescription
classNamestring

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.
activeIdstring

Required

Configures activeId for this component.
onChange(tabId: string) => void

Configures onChange for this component.
idPrefixstring

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

PropertyTypeRequiredDescription
tabsTabItem[]

Yes

Configures tabs for this component.

activeIdstring

Yes

Configures activeId for this component.

childrenChild

No

Inherited children attribute accepted by Tabs.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

onChange(tabId: string) => void

No

Configures onChange for this component.

idPrefixstring

No

Configures idPrefix for this component.

orientation"horizontal" | "vertical"

No

Configures orientation for this component.

State ownership and DOM target

ConcernContract
StateApplication controlled through activeId and the matching callback.
DOM targetPublic 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

ContractCurrent value
Maturitystable
Categorycontent
Component import@tavojs/ui/tabs
Explicit CSS import@tavojs/ui/css/tabs
PreviewInteractive preview available on this page