Skip to content

Tabs

Switch between panels on a page, or between routes. Comes in line, segmented, pills and button styles.

// Radix — @radix-ui/react-tabs
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@shavin/ui";

States and navigation

as="states" (the default) switches panels on the page, built on Radix Tabs. as="navigation" renders links inside a nav, for moving between routes.

as="states"

March spending is $2,340, $160 under budget.

as="navigation"

Component Source
const STATE_TABS = [
  { value: "overview", label: "Overview", content: <Text color="muted">March spending is $2,340, $160 under budget.</Text> },
  { value: "bills", label: "Bills", content: <Text color="muted">4 bills due this month. Rent is paid.</Text> },
  { value: "goals", label: "Goals", content: <Text color="muted">Summer trip fund is 62% of the way there.</Text> },
];

<Tabs as="states" items={STATE_TABS} />

const NAV_LINKS = [
  { value: "overview", href: "#overview", label: "Overview" },
  { value: "budgets", href: "#budgets", label: "Budgets" },
  { value: "reports", href: "#reports", label: "Reports" },
];

<Tabs as="navigation" value="overview" items={NAV_LINKS} />

Active link and router links

In navigation mode a link is active when its item sets active, or when the value prop matches the item's value. Pass the current route segment as value. Links render as a plain a by default. Pass linkComponent={Link} from next/link (or your router's link) for client-side navigation. Items with external open in a new tab.

Next.js Link

Component Source
import Link from "next/link";

const NAV_LINKS = [
  { value: "overview", href: "#overview", label: "Overview" },
  { value: "budgets", href: "#budgets", label: "Budgets" },
  { value: "reports", href: "#reports", label: "Reports" },
];

<Tabs as="navigation" linkComponent={Link} value="budgets" items={NAV_LINKS} />

Variants

line (the default), segmented, pills and button. Both modes take the same variants.

States mode

Line

March spending is $2,340, $160 under budget.

Segmented

March spending is $2,340, $160 under budget.

Pills

March spending is $2,340, $160 under budget.

Button

March spending is $2,340, $160 under budget.

Component Source
const STATE_TABS = [
  { value: "overview", label: "Overview", content: <Text color="muted">March spending is $2,340, $160 under budget.</Text> },
  { value: "bills", label: "Bills", content: <Text color="muted">4 bills due this month. Rent is paid.</Text> },
  { value: "goals", label: "Goals", content: <Text color="muted">Summer trip fund is 62% of the way there.</Text> },
];

<Tabs as="states" variant="line" items={STATE_TABS} />
<Tabs as="states" variant="segmented" items={STATE_TABS} />
<Tabs as="states" variant="pills" items={STATE_TABS} />
<Tabs as="states" variant="button" items={STATE_TABS} />

Navigation mode

Component Source
const NAV_LINKS = [
  { value: "overview", href: "#overview", label: "Overview" },
  { value: "budgets", href: "#budgets", label: "Budgets" },
  { value: "reports", href: "#reports", label: "Reports" },
];

<Tabs as="navigation" variant="line" value="overview" items={NAV_LINKS} />
<Tabs as="navigation" variant="segmented" value="overview" items={NAV_LINKS} />
<Tabs as="navigation" variant="pills" value="overview" items={NAV_LINKS} />
<Tabs as="navigation" variant="button" value="overview" items={NAV_LINKS} />

Vertical orientation

orientation="vertical" stacks the tabs, for sidebars and settings pages.

variant="segmented"

variant="pills"

variant="button"

Component Source
const NAV_LINKS = [
  { value: "overview", href: "#overview", label: "Overview" },
  { value: "budgets", href: "#budgets", label: "Budgets" },
  { value: "reports", href: "#reports", label: "Reports" },
];

<Tabs as="navigation" variant="line" orientation="vertical" value="overview" items={NAV_LINKS} />
<Tabs as="navigation" variant="segmented" orientation="vertical" value="overview" items={NAV_LINKS} />
<Tabs as="navigation" variant="pills" orientation="vertical" value="overview" items={NAV_LINKS} />
<Tabs as="navigation" variant="button" orientation="vertical" value="overview" items={NAV_LINKS} />

Sizes

size="md" is the default. size="sm" uses smaller text and padding.

Component Source
const NAV_LINKS = [
  { value: "overview", href: "#overview", label: "Overview" },
  { value: "budgets", href: "#budgets", label: "Budgets" },
  { value: "reports", href: "#reports", label: "Reports" },
];

<Tabs as="navigation" size="sm" value="overview" items={NAV_LINKS} />
<Tabs as="navigation" size="md" value="overview" items={NAV_LINKS} />

Props

SegmentedControl or Tabs? Use SegmentedControl to switch a view mode or filter with no panels. Use Tabs for content panels or page navigation.
PropTypeDefaultDescription
as"states" | "navigation"—Mode: "states" for in-page stateful panels (default), "navigation" for URL routing links.
variantTabVariant—Visual variant: "line" (default), "segmented", "pills", or "button".
orientation"horizontal" | "vertical"—Layout orientation: "horizontal" (default) or "vertical".
size"sm" | "md"—Component size: "sm" (small) or "md" (medium, default).
valuestring——
defaultValuestring——
onValueChange(value: string) => void——
itemsreadonly TabItem[]—List of tab items.
tabsreadonly TabItem[]—Alias for items when passing data-driven tabs.
linkComponentElementType—Router component for as="navigation" mode (defaults to "a").
childrenReactNode——
classNamestring——
Configure Theme
Theme
Brand Color
Custom
Gray Family
Appearance
Radius
Scaling
Panel Style
Heading Font
Body Font