Keyboard-navigable content tabs with quiet pill or underline styling and a clear selected state in both themes.
What changed
- 1.0.1 Oct 11, 2026Control heights, menu and sidebar row sizes, press dimming and frosted surfaces follow the platform feel tokens (--bm-control-h, --bm-menu-*, --bm-sidebar-*, --bm-material-*). Unchanged without a feel.
- 1.0.0 Sep 30, 2026First release.
Your workspace at a glance
24
Active files
8
Teammates
import { Activity, Files, Users } from "lucide-react";
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from "@/components/ballmac/tabs";
export default function TabsDemo() {
return (
<Tabs
defaultValue="overview"
className="w-full max-w-sm rounded-xl border bg-card p-4 shadow-sm"
>
<TabsList aria-label="Workspace views">
<TabsTrigger value="overview">
<Activity aria-hidden="true" className="size-4" />
Overview
</TabsTrigger>
<TabsTrigger value="files">
<Files aria-hidden="true" className="size-4" />
Files
</TabsTrigger>
<TabsTrigger value="team">
<Users aria-hidden="true" className="size-4" />
Team
</TabsTrigger>
</TabsList>
<TabsContent value="overview">
<p className="text-sm font-semibold">Your workspace at a glance</p>
<div className="mt-3 grid grid-cols-2 gap-2">
<div className="rounded-lg border bg-background p-3">
<p className="text-2xl font-semibold tabular-nums">24</p>
<p className="text-xs text-muted-foreground">Active files</p>
</div>
<div className="rounded-lg border bg-background p-3">
<p className="text-2xl font-semibold tabular-nums">8</p>
<p className="text-xs text-muted-foreground">Teammates</p>
</div>
</div>
</TabsContent>
<TabsContent value="files">
<p className="text-sm font-semibold">Recent files</p>
<p className="mt-2 text-sm text-muted-foreground">
Product brief · Brand guide · Launch checklist
</p>
</TabsContent>
<TabsContent value="team">
<p className="text-sm font-semibold">People in this workspace</p>
<p className="mt-2 text-sm text-muted-foreground">
8 teammates can collaborate here.
</p>
</TabsContent>
</Tabs>
);
}Installation
The default, and what a Radix-style project installs.
$ pnpm dlx shadcn@latest add @ballmac/tabsInstall the dependencies.
$ pnpm add radix-uiAdd the Ballmac items it builds on.
$ pnpm dlx shadcn@latest add @ballmac/directionCopy the source into your project.
components/ballmac/tabs.tsx// Ballmac UI: Tabs. https://ui.ballmac.com/components/tabs "use client"; import * as React from "react"; import { Tabs as Primitive } from "radix-ui"; import { useDirection } from "@/lib/ballmac/direction"; import { cn } from "@/lib/utils"; type TabsProps = React.ComponentProps<typeof Primitive.Root>; function Tabs({ className, ...props }: TabsProps) { const dir = useDirection(props.dir); return ( <Primitive.Root dir={dir} data-slot="tabs" className={cn("flex min-w-0 flex-col gap-4", className)} {...props} /> ); } type TabsListProps = React.ComponentProps<typeof Primitive.List> & { /** Visual treatment of the selected tab. */ variant?: "pills" | "underline"; }; function TabsList({ className, variant = "pills", ...props }: TabsListProps) { return ( <Primitive.List data-slot="tabs-list" data-variant={variant} className={cn( "inline-flex max-w-full items-center gap-1 self-start overflow-x-auto rounded-lg p-1 text-muted-foreground", variant === "pills" ? "bg-muted" : "rounded-none border-b bg-transparent pb-0", className, )} {...props} /> ); } type TabsTriggerProps = React.ComponentProps<typeof Primitive.Trigger>; function TabsTrigger({ className, ...props }: TabsTriggerProps) { return ( <Primitive.Trigger data-slot="tabs-trigger" className={cn( "inline-flex min-h-[var(--bm-control-h,calc(var(--spacing)*9))] shrink-0 items-center justify-center gap-2 rounded-md px-3 text-sm font-medium whitespace-nowrap outline-none transition-[color,background-color,box-shadow] duration-150 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50 data-[state=active]:text-foreground [[data-variant=pills]_&]:data-[state=active]:bg-background [[data-variant=pills]_&]:data-[state=active]:shadow-xs [[data-variant=underline]_&]:rounded-none [[data-variant=underline]_&]:border-b-2 [[data-variant=underline]_&]:border-transparent [[data-variant=underline]_&]:data-[state=active]:border-primary motion-reduce:transition-none", className, )} {...props} /> ); } type TabsContentProps = React.ComponentProps<typeof Primitive.Content>; function TabsContent({ className, ...props }: TabsContentProps) { return ( <Primitive.Content data-slot="tabs-content" className={cn( "min-w-0 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50", className, )} {...props} /> ); } export { Tabs, TabsList, TabsTrigger, TabsContent, type TabsProps, type TabsListProps, type TabsTriggerProps, type TabsContentProps, };Update the import paths to match your project setup.
$ pnpm dlx shadcn@latest add https://ui.ballmac.com/r/base/tabs.jsonInstall the dependencies.
$ pnpm add @base-ui/react@^1.9.0Add the Ballmac items it builds on (their Base UI versions where they have one).
$ pnpm dlx shadcn@latest add https://ui.ballmac.com/r/base/direction.jsonCopy the source into your project.
components/ballmac/tabs.tsx// Ballmac UI: Tabs. https://ui.ballmac.com/components/tabs "use client"; import * as React from "react"; import { Tabs as Primitive } from "@base-ui/react/tabs"; import { DirectionProvider, useDirection } from "@/lib/ballmac/direction"; import { cn } from "@/lib/utils"; const ActivationContext = React.createContext<"automatic" | "manual">("automatic"); type TabsProps = Omit<React.ComponentProps<typeof Primitive.Root>, "className"> & { className?: string; /** Reading direction for the arrow keys. Defaults to the page's. */ dir?: "ltr" | "rtl"; /** "automatic" selects a tab as soon as it takes focus. "manual" waits for Enter or Space. */ activationMode?: "automatic" | "manual"; }; function Tabs({ className, dir: dirProp, activationMode = "automatic", ...props }: TabsProps) { const dir = useDirection(dirProp); return ( <DirectionProvider dir={dir}> <ActivationContext.Provider value={activationMode}> <Primitive.Root dir={dir} data-slot="tabs" className={cn("flex min-w-0 flex-col gap-4", className)} {...props} /> </ActivationContext.Provider> </DirectionProvider> ); } type TabsListProps = Omit<React.ComponentProps<typeof Primitive.List>, "className"> & { className?: string; /** Visual treatment of the selected tab. */ variant?: "pills" | "underline"; }; function TabsList({ className, variant = "pills", ...props }: TabsListProps) { const mode = React.useContext(ActivationContext); return ( <Primitive.List data-slot="tabs-list" data-variant={variant} activateOnFocus={mode === "automatic"} className={cn( "inline-flex max-w-full items-center gap-1 self-start overflow-x-auto rounded-lg p-1 text-muted-foreground", variant === "pills" ? "bg-muted" : "rounded-none border-b bg-transparent pb-0", className, )} {...props} /> ); } type TabsTriggerProps = Omit<React.ComponentProps<typeof Primitive.Tab>, "className"> & { className?: string }; function TabsTrigger({ className, ...props }: TabsTriggerProps) { return ( <Primitive.Tab data-slot="tabs-trigger" className={cn( "inline-flex min-h-[var(--bm-control-h,calc(var(--spacing)*9))] shrink-0 items-center justify-center gap-2 rounded-md px-3 text-sm font-medium whitespace-nowrap outline-none transition-[color,background-color,box-shadow] duration-150 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50 data-active:text-foreground [[data-variant=pills]_&]:data-active:bg-background [[data-variant=pills]_&]:data-active:shadow-xs [[data-variant=underline]_&]:rounded-none [[data-variant=underline]_&]:border-b-2 [[data-variant=underline]_&]:border-transparent [[data-variant=underline]_&]:data-active:border-primary motion-reduce:transition-none", className, )} {...props} /> ); } type TabsContentProps = Omit<React.ComponentProps<typeof Primitive.Panel>, "className"> & { className?: string }; function TabsContent({ className, ...props }: TabsContentProps) { return ( <Primitive.Panel data-slot="tabs-content" className={cn( "min-w-0 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50", className, )} {...props} /> ); } export { Tabs, TabsList, TabsTrigger, TabsContent, type TabsProps, type TabsListProps, type TabsTriggerProps, type TabsContentProps, };Update the import paths to match your project setup.
Usage
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ballmac/tabs"The full example is in the Code tab above.
Examples
Underline tabs
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from "@/components/ballmac/tabs";
export default function TabsStates() {
return (
<Tabs defaultValue="activity" className="w-full max-w-sm">
<TabsList variant="underline" aria-label="Project details">
<TabsTrigger value="activity">Activity</TabsTrigger>
<TabsTrigger value="details">Details</TabsTrigger>
<TabsTrigger value="settings">Settings</TabsTrigger>
</TabsList>
<TabsContent
value="activity"
className="pt-2 text-sm text-muted-foreground"
>
Your latest project updates appear here.
</TabsContent>
<TabsContent
value="details"
className="pt-2 text-sm text-muted-foreground"
>
Shared project information and files.
</TabsContent>
<TabsContent
value="settings"
className="pt-2 text-sm text-muted-foreground"
>
Manage access and notifications.
</TabsContent>
</Tabs>
);
}API reference
| Prop | Type | Default |
|---|---|---|
variantVisual treatment of the selected tab. | "pills" | "underline" | "pills" |
Also accepts the standard attributes of its root element.
Accessibility
| Key | Action |
|---|---|
| Tab | Focuses the active tab |
| Arrow keys / Home / End | Moves among tabs |
| Tab again | Moves into the active panel |
Quality scorecard
Every applicable check passes
Measured in Chromium 153.0.8010.12 on October 19, 2026, on version 1.0.1, across 2 examples.
Passed: Accessibility scan
No serious or critical issues in light and dark, on a phone and a desktop (axe-core 4.13.0, WCAG 2.1 AA and best-practice rules).
Passed: Small screens
No sideways scrolling at 360, 390 or 1280 px wide.
Passed: Reduced motion
No endless animation to begin with.
Passed: Right to left
Mirrors correctly in Arabic, Hebrew, Persian and Urdu layouts (0% of elements off the mirror, limit 15%).
Passed: Clean console
No console errors or React hydration errors while loading.
Passed: Keyboard
4 tab stops, each showing a visible change when it takes focus. 3 documented keys.
Not applicable: Loading, empty and error
Does not show data or take submissions.
Passed: Automated tests
Covered by direction.test.tsx, tabs.test.tsx.
For information: Footprint
0.9 KB of source (gzip) in 1 file. Installs radix-ui.
Automated checks find a subset of problems and do not replace testing with a screen reader and a keyboard in your own app. What they miss.
Use with AI
Switches between a small number of peer views while retaining Radix tablist semantics and roving focus. With the shadcn MCP server set up (guide), ask your agent:
Add the Ballmac UI Tabs (@ballmac/tabs) to this project with the shadcn MCP, then use it where it fits.
Use it for
- Related panels within one page
- Compact dashboards and detail views
Not for
- Steps in a workflow; use progress-steps
- Site navigation to separate pages
Registry JSON: https://ui.ballmac.com/r/tabs.json
Credits
Free to use in personal and commercial projects.
- npm
- radix-ui
- Registry
- @ballmac/directionshadcn/utils
Pairs well with
Card
A composable content surface with compact spacing, an action slot, and optional interactive feedback.
Badge
A small pill label in four variants with an optional status dot and success, warning and error tones. Style links with badgeVariants().
Animated Tabs
Radix Tabs with a pill or underline indicator that slides between triggers on a spring, and panels that fade in. Keeps full keyboard support and ARIA; controlled or uncontrolled.
Back To Top
A floating button that appears after scrolling, draws a progress ring, scrolls smoothly (instantly under reduced motion) and moves focus to the content.
Ballmac UI Pro
Need the whole screen, not one piece?
311 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.
Not ready? Try three Pro blocks free
Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.