Switch between views in place: underline, pill and button styles, a sidebar-style vertical list, icons and counts, and a sliding indicator. Arrow keys move.
Used for
- Run logs and output
- Settings sections
- Ticket views
- Agent trace modes
Examples
Variant
Size
Activation
Links
Installation
npx knowns-ui@latest add tabsFor Claude Code, Cursor or Codex: installs it and wires the props to your own data.
Paste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install prompt
Install Tabs from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/tabs
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add tabs
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/tabs.tsx
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/tabs, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "tabs" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.Props
- Tabs.value / defaultValue
string- Controlled or uncontrolled selected tab.
- Tabs.onValueChange
(value: string) => void- Called when a different tab is selected.
- Tabs.variant
"underline"|"pill"|"button"- Default
"underline" - A line under the active tab, a raised pill on a muted track, or joined bordered segments. The indicator slides between tabs (transform, ease-out; off with reduced motion).
- Tabs.size
"sm"|"md"- Default
"md" - Underline 32 / 36px, pill 24 / 28px (+ track), button 28 / 32px.
- Tabs.orientation
"horizontal"|"vertical"- Default
"horizontal" - Vertical puts the list beside the panels like a sidebar; ↑ ↓ move, aria-orientation is set.
- Tabs.activationMode
"automatic"|"manual"- Default
"automatic" - Automatic: arrows move focus and select. Manual: arrows move focus; Enter or Space selects.
- Tabs.fullWidth
boolean- Default
false - Horizontal tabs share the full width equally.
- Tabs.links
boolean- Default
false - Link mode for tabs that are routes. Triggers with an href render as links (Ctrl or Cmd click opens a new tab), the list is a nav landmark named by TabsList's aria-label, the current link has aria-current="page", and there is no tablist, tab role or arrow roving.
- TabsList
{ aria-label | aria-labelledby, variant?, size?, fullWidth?, flush?, className? }- Names the tablist; can override Tabs' look. Scrolls sideways when tabs don't fit, fading the clipped edges; the selected tab is kept in view.
- TabsTrigger
{ value, children, icon?, badge?, disabled?, href?, onClick?, className? }- One tab. badge shows a count or short text after the label and is read as part of its name. Disabled tabs are skipped by the arrows.
- TabsContent
{ value, children, keepMounted?, className? }- The panel for that value, linked to its tab. keepMounted keeps it in the DOM (hidden) so its state survives.
- Keys
← → (↑ ↓ vertical), Home, End- Wrap around and skip disabled tabs. Only the selected tab is in the Tab order.
| Prop | Type | Default | Description |
|---|---|---|---|
| Tabs.value / defaultValue | string | - | Controlled or uncontrolled selected tab. |
| Tabs.onValueChange | (value: string) => void | - | Called when a different tab is selected. |
| Tabs.variant | "underline" | "pill" | "button" | "underline" | A line under the active tab, a raised pill on a muted track, or joined bordered segments. The indicator slides between tabs (transform, ease-out; off with reduced motion). |
| Tabs.size | "sm" | "md" | "md" | Underline 32 / 36px, pill 24 / 28px (+ track), button 28 / 32px. |
| Tabs.orientation | "horizontal" | "vertical" | "horizontal" | Vertical puts the list beside the panels like a sidebar; ↑ ↓ move, aria-orientation is set. |
| Tabs.activationMode | "automatic" | "manual" | "automatic" | Automatic: arrows move focus and select. Manual: arrows move focus; Enter or Space selects. |
| Tabs.fullWidth | boolean | false | Horizontal tabs share the full width equally. |
| Tabs.links | boolean | false | Link mode for tabs that are routes. Triggers with an href render as links (Ctrl or Cmd click opens a new tab), the list is a nav landmark named by TabsList's aria-label, the current link has aria-current="page", and there is no tablist, tab role or arrow roving. |
| TabsList | { aria-label | aria-labelledby, variant?, size?, fullWidth?, flush?, className? } | - | Names the tablist; can override Tabs' look. Scrolls sideways when tabs don't fit, fading the clipped edges; the selected tab is kept in view. |
| TabsTrigger | { value, children, icon?, badge?, disabled?, href?, onClick?, className? } | - | One tab. badge shows a count or short text after the label and is read as part of its name. Disabled tabs are skipped by the arrows. |
| TabsContent | { value, children, keepMounted?, className? } | - | The panel for that value, linked to its tab. keepMounted keeps it in the DOM (hidden) so its state survives. |
| Keys | ← → (↑ ↓ vertical), Home, End | - | Wrap around and skip disabled tabs. Only the selected tab is in the Tab order. |
What it handles
- 01Builds Tabs, TabsList, TabsTrigger and TabsPanel parts in three looks through variant: underline, pill and button.
- 02Moves with the arrow keys for the orientation (Left and Right, or Up and Down when vertical, mirrored in right-to-left text), plus Home and End, skipping disabled tabs.
- 03Selects as focus moves in automatic activation, or only on Enter and Space in manual, set by activationMode.
- 04Slides one indicator between tabs, measured from the real tab boxes, and re-measures when a tab resizes.
- 05Scrolls a long horizontal list, fades the clipped ends with a mask, and brings the selected tab back into view.
- 06Adds an icon and a badge count to a trigger, and keepMounted holds a hidden panel in the DOM so its state survives.
States
- First render
- Nothing. The indicator sits on the selected tab with no slide
- none
- Selection changes
- The indicator slides and resizes to the new tab
- 180ms, ease out
- Tab hover
- The tab text colour changes
- 120ms, ease out
- Panel switch
- The old panel is hidden and the new one shows at once
- none
- Reduced motion
- The indicator jumps to the new tab
- 0ms
| State | What moves | Timing |
|---|---|---|
| First render | Nothing. The indicator sits on the selected tab with no slide | none |
| Selection changes | The indicator slides and resizes to the new tab | 180ms, ease out |
| Tab hover | The tab text colour changes | 120ms, ease out |
| Panel switch | The old panel is hidden and the new one shows at once | none |
| Reduced motion | The indicator jumps to the new tab | 0ms |
Works with
When to use
When to use
- Switching between panels of related content on one page.
When not to use
- A view or mode switch without panels: use Segmented Control.
- Steps that must happen in order: use Stepper.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Tabs to my app and wire it to my own data.
- I need switching between panels of related content on one page. Set that up with the Knowns UI Tabs.
- Which Tabs props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "tabs" }) and search_docs({ query: "tabs" }).