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

TSX
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

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

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

TSXCreate: src/components/examples/TabsExample1.tsx
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.

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
StateUse activeId to supply rendered state. Update it through the documented callback or native event handler.
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