Tabs
Views of the same page, one at a time: underlined sections, a segmented switch, pills or binder dividers that organise collections — one light glides from the active tab to the next.
- Domaine
- Navigation et cadre
- Niveau de support
- Taille
- 4.7 kB gzip, budget 12.3 kB
- Qui l'utilise
- 25 fichiers des produits et sites en production l'importent (Verikora : 6, Folioviv : 2, Sovkora : 8) Compté dans l'inventaire daté du 2026-11-23.
import { Tabs } from "@krizaka/ui/tabs";Web et mobile — le même composant pour React et React Native. Bêta : son API peut encore changer à une version mineure.
Pourquoi il est là. Used by Sovkora, Verikora, Folioviv.
Quand l’utiliser
- To split a page into sections the user switches between without leaving it: videos, stories, about.
variant="segmented"for a view switch (grid, list);pillsfor a feed's sections.variant="binder"to organise a workspace's collections, tags or statuses as binder dividers (intercalaires): a coloured edge (hue), the words and a count; best as routes (Tabs.Nav), so the address is the state.
Quand ne pas l’utiliser
- For a filter that narrows a list.À la place : Chip
- To go to other pages from a tablist: use
Tabs.Nav(links), notTabs.Trigger. - For a choice in a form.À la place : Radio group
Installation
Installer
npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcssStyles
@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";Importer
import { Tabs } from "@krizaka/ui/tabs";Exemples
Underline
The sections of a page; a disabled tab is skipped.
Segmented
A view switch: equal segments in a track.
Pills
A feed's sections, scrolling sideways on a phone.
Vertical
orientation="vertical": the list on the side.
Binder dividers
variant="binder" as routes: a client's collections as dividers with their colour and count, « + Divider » after them; they scroll sideways with fading edges when they do not fit.
Tabs as routes
Tabs.Nav + Tabs.NavLink: each tab is a link, the active one comes from the current route (aria-current="page"), the URL is the state.
Props
TabsRoot
value/defaultValue + onValueChange, orientation (horizontal by default), variant for the list.
| Prop | Type | Défaut | Description |
|---|---|---|---|
routeKey | string | — | Binds the active tab to this search parameter of the URL (?tab=…): the URL is the state. Without it the state is local — only for an ephemeral choice. |
routeValues | readonly string[] | — | The values the parameter may hold (the tabs' values); the first is the default unless defaultValue says otherwise. |
variant | "segmented" | "underline" | "pills" | "binder" | underline | underline (the sections of a page) · segmented (a view switch) · pills (a feed's sections) · binder (dividers that organise collections, tags, statuses). |
TabsList
The tabs. Name it (aria-label) when no heading says what it switches. One light glides to the active tab.
| Prop | Type | Défaut | Description |
|---|---|---|---|
add | TabsAdd | — | A « + » button after the tabs (variant="binder": « + Intercalaire »): its words and what it does. |
TabsTrigger
| Prop | Type | Défaut | Description |
|---|---|---|---|
count | number | — | A count after the words (clients in a collection, unread): part of the tab's name. |
hue | TabsHue | — | variant="binder": the divider's colour (the accent by default). |
TabsNav
Tabs as routes: a nav of links, the URL is the state. Per WAI-ARIA these are links, not a tablist: each tab is an
anchor, the active one carries aria-current="page", the keyboard is the page's own (Tab walks the links, Enter
follows one) and there is no panel — the page is the panel. The same looks and the same gliding light as Tabs.List.
| Prop | Type | Défaut | Description |
|---|---|---|---|
childrenrequis | ReactNode | — | The tabs: Tabs.NavLink. |
currentrequis | string | — | The current route, passed in: the path with its search (usePathname() + useSearchParams(), /docs?tab=api). The active tab comes from it; no local state. |
labelrequis | string | — | The navigation's accessible name (« Sections »). |
add | TabsAdd | — | A « + » button after the tabs (variant="binder": « + Intercalaire »). |
variant | "segmented" | "underline" | "pills" | "binder" | underline | underline (the sections of a page) · segmented (a view switch) · pills (a feed's sections) · binder (dividers). |
TabsNavLink
One tab of Tabs.Nav: an anchor that is active when the current route is its href.
| Prop | Type | Défaut | Description |
|---|---|---|---|
asChild | boolean | — | Renders your router's <Link> (pass it as the only child; the href goes on this part and on the link). |
count | number | — | A count after the words (not with asChild: put it in your link). |
exact | boolean | — | Match this path only, not the pages below it. |
hue | TabsHue | — | variant="binder": the divider's colour (the accent by default). |
Accessibilité
- Radix Tabs:
tablist,tabwitharia-selectedandaria-controls,tabpanel; name the list witharia-label. - A disabled tab is skipped.
- A count is part of the tab's name (« Regulars 21 »); a binder divider's colour is decoration (the words say it).
- The binder's « + » is a button after the list (a tablist holds only tabs), reached by Tab after the tabs.
Clavier
| Touches | Action |
|---|---|
| Tab | Moves to the active tab, then into its panel. |
| Arrow keys / Home / End | Move between tabs and activate them. |
Bonnes pratiques
- Short labels of one or two words; the active one should be clear without colour.
- Binder: the colour organises, it never says on its own — the words and the count do.
huetakes a role of the theme (accent · success · warning · danger · neutral), each 3:1 or more on both themes; give a status divider its status' role. No paper texture: it is the products' register. - Binder: « + » (
add) sits after the dividers, outside the tab list, for creating a collection. - Keep the URL in sync with the active tab when a tab is worth sharing: better, use
Tabs.Nav(tabs as routes), where the route is the state and the active tab is read from it.
Composants liés
Générée depuis le code de @krizaka/ui 5.3.4 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub