Documentation

Tabs

Views of the same page, one at a time: underlined sections, a segmented switch or pills.

WebBêtaNavigation

Web uniquement — React, depuis @krizaka/ui/tabs. Bêta : son API peut encore changer à une version mineure.

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); pills for a feed's sections.

Quand ne pas l’utiliser

  • For a filter that narrows a list.À la place : Chip
  • To go to other pages: use links in the navigation.
  • For a choice in a form.À la place : Radio group

Installation

Installer

npm install @krizaka/ui@beta @krizaka/tailwind@beta @krizaka/tokens@beta tailwindcss

Styles

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

Twelve videos, newest first.

Segmented

A view switch: equal segments in a track.

Four columns of cards.

Pills

A feed's sections, scrolling sideways on a phone.

Twelve videos, newest first.

Vertical

orientation="vertical": the list on the side.

Twelve videos, newest first.

Props

value/defaultValue + onValueChange, orientation (horizontal by default), variant for the list.

PropTypeDéfautDescription
variant"underline" | "segmented" | "pills"underlineunderline (the sections of a page) · segmented (a view switch) · pills (a feed's sections).

Accessibilité

  • Radix Tabs: tablist, tab with aria-selected and aria-controls, tabpanel; name the list with aria-label.
  • A disabled tab is skipped.

Clavier

TouchesAction
TabMoves to the active tab, then into its panel.
Arrow keys / Home / EndMove between tabs and activate them.

Bonnes pratiques

  • Short labels of one or two words; the active one should be clear without colour.
  • Keep the URL in sync with the active tab when a tab is worth sharing.

Générée depuis le code de @krizaka/ui 2.0.0-beta.6 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub

Sur cette page