Skip to content
Alea0.1

Navigation

Tabs

Switch between views of the same thing. Underline or pills, horizontal or vertical.

Ant Design: Tabs

import { Tabs, TabList, Tab, TabPanel } from '@alea/ui';

Examples

Tabs

The underline grows in with the accent gradient.

Generates a full color system as Figma variables.

Pills

The segmented look, with icons.

The live component.

Vertical

For settings pages.

Name and description.

Props

Tabs props

Switch between views. Arrow keys move between tabs; Home and End jump.

PropTypeDefaultDescription
variant"underline" | "pills"'underline'underline (default) or pills (the segmented look).

TabList props

The row of tabs. Needs an aria-label when there is no visible heading for it.

PropTypeDefaultDescription
aria-labelstring-Defines a string value that labels the current element. (React Aria)
childrenReactNode | ((item: T) => ReactNode)-The contents of the collection. (React Aria)
classNameClassNameOrFunction<TabsRenderProps>-The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state. (React Aria)
styleStyleOrFunction<DisclosureGroupRenderProps>-The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. A function may be provided to compute the style based on component state. (React Aria)

Tab props

One tab; its id matches a TabPanel.

PropTypeDefaultDescription
aria-labelstring-Defines a string value that labels the current element. (React Aria)
childrenChildrenOrFunction<DisclosureGroupRenderProps>-The children of the component. A function may be provided to alter the children based on component state. (React Aria)
classNameClassNameOrFunction<TabsRenderProps>-The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state. (React Aria)
hrefstring-A URL to link to. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href). (React Aria)
idKey-The unique id of the tab. (React Aria)
isDisabledboolean-Whether the tab is disabled. (React Aria)
onPress((e: PressEvent) => void)-Handler that is called when the press is released over the target. (React Aria)
styleStyleOrFunction<DisclosureGroupRenderProps>-The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. A function may be provided to compute the style based on component state. (React Aria)
targetHTMLAttributeAnchorTarget-The target window for the link. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target). (React Aria)

TabPanel props

The content for the tab with the same id.

PropTypeDefaultDescription
aria-labelstring-Defines a string value that labels the current element. (React Aria)
childrenChildrenOrFunction<DisclosureGroupRenderProps>-The children of the component. A function may be provided to alter the children based on component state. (React Aria)
classNameClassNameOrFunction<TabsRenderProps>-The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state. (React Aria)
idKey-The unique id of the tab. (React Aria)
styleStyleOrFunction<DisclosureGroupRenderProps>-The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. A function may be provided to compute the style based on component state. (React Aria)

Accessibility

  • Tab list, tabs and panels are wired with ARIA; the selected tab is the only tab stop.

Keyboard

KeyDoes
Arrow keysMove between tabs
Home / EndFirst / last tab
TabMoves into the panel

Do and don't

Do

  • Keep tab labels short.

Don't

  • Don't use tabs for steps in a process.
Tested with axe, keyboard and screen reader roles