Tab
- Stable
- WCAG 2.2 evidence
- RTL
One tab of a horizontal TabList. Built on React Aria Tab: role tab with aria-selected and
aria-controls; inside the tab list the arrow keys move between tabs (mirrored in right-to-left locales), Home and End jump
to the first and last tab, Tab moves into the panel, and disabled tabs are skipped (WCAG 2.1.1, 4.1.2). Selection follows
focus by default (keyboardActivation="automatic" on Tabs); set keyboardActivation="manual" there when showing a panel is
slow, so Enter or Space selects. With href the tab is a link and navigation is the router's job. The selected tab is shown by its underline, fill or box and a heavier label, not by colour alone (1.4.1). Keyboard focus
shows the ring inside the tab, so the scrolling strip never clips it (2.4.7, 2.4.11). For side navigation in settings
pages use VerticalTab. Consumer duties: short, translated labels that match the panels; a name for the TabList.
import { Tab } from "@nexera-ui/react";- 5
- examples
- 25
- props
- 3
- live controls
- 1
- platform
- 10
- WCAG criteria
- 3
- blocks use it
Try every prop. Copy the code.
Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.
import { Tab } from "@nexera-ui/react";
<Tab />Examples 4
The same examples as Storybook, rendered live. Open Code to copy one.
Variants and sizes
Every Figma Variant and Size. Hover, focus and select the tabs to see the other states.
import { Tab, TabList, TabPanel, Tabs } from "@nexera-ui/react";
const variants = ["underline", "pill", "enclosed"] as const;
const sizes = ["sm", "md"] as const;
export function VariantsAndSizes() {
return (
<div className="flex flex-col gap-6">
{variants.flatMap((variant) =>
sizes.map((size) => (
<Tabs key={`${variant}${size}`} defaultSelectedKey="overview">
<TabList aria-label={`${variant} ${size}`} variant={variant}>
<Tab id="overview" label="Overview" size={size} />
<Tab id="documents" label="Documents" size={size} />
<Tab id="payroll" label="Payroll" size={size} />
</TabList>
<TabPanel id="overview" className="sr-only">
Overview panel
</TabPanel>
</Tabs>
)),
)}
</div>
);
}
With icon and count
Figma Show icon and Show count: a 16 / 18 px icon before the label and a count pill after it.
import { Tab, TabList, TabPanel, Tabs } from "@nexera-ui/react";
import { LuFileText, LuLayoutDashboard, LuUsers } from "react-icons/lu";
const variants = ["underline", "pill", "enclosed"] as const;
export function WithIconAndCount() {
return (
<div className="flex flex-col gap-6">
{variants.map((variant) => (
<Tabs key={variant} defaultSelectedKey="dashboard">
<TabList aria-label={`Workspace (${variant})`} variant={variant}>
<Tab id="dashboard" label="Dashboard" icon={<LuLayoutDashboard />} />
<Tab id="people" label="People" icon={<LuUsers />} count="24" />
<Tab id="documents" label="Documents" icon={<LuFileText />} count="4" />
</TabList>
<TabPanel id="dashboard" className="sr-only">
Dashboard panel
</TabPanel>
</Tabs>
))}
</div>
);
}
Disabled
Figma Disabled state: the tab is skipped by the arrow keys and cannot be selected.
import { Tab, TabList, TabPanel, Tabs } from "@nexera-ui/react";
export function Disabled() {
return (
<Tabs defaultSelectedKey="overview">
<TabList aria-label="Employee">
<Tab id="overview" label="Overview" />
<Tab id="payroll" label="Payroll" isDisabled count="2" />
<Tab id="documents" label="Documents" />
</TabList>
<TabPanel id="overview" className="py-4">
The overview panel.
</TabPanel>
</Tabs>
);
}
Right to left
Right-to-left: the order of the tabs and the arrow keys mirror; the count stays after the label.
import { Tab, TabList, TabPanel, Tabs } from "@nexera-ui/react";
export function RightToLeft() {
return (
<Tabs defaultSelectedKey="overview">
<TabList aria-label="الموظف" variant="underline">
<Tab id="overview" label="نظرة عامة" />
<Tab id="documents" label="المستندات" count="4" />
<Tab id="time-off" label="الإجازات" />
</TabList>
<TabPanel id="overview" className="py-4">
لوحة نظرة عامة.
</TabPanel>
</Tabs>
);
}
Props 25
Press "Try it" on a card to load that prop into the playground.
25 props shown
id*NexeraKeyKey of the tab. The TabPanel with the same id is the panel it shows; selectedKey and onSelectionChange use it.
label*NexeraVisibleContentVisible label: a 1 or 2 word noun that matches the panel's content ("Overview", "Documents"). It names the tab and stays on one line; a list with too many tabs scrolls horizontally.
iconNexeraReactNodeIcon before the label: 16 px at sm, 18 px at md. Decorative: the label names the tab.
countNexerastringCount after the label, for example "4". It is read as part of the tab's name ("Documents 4"); make sure the number makes sense in that sentence.
variantNexera"underline" | "pill" | "enclosed"Look. Defaults to the variant of the enclosing TabList, so set it there once.
sizeNexera"sm" | "md"Height, padding and type: 32 px (Body/Small) or 40 px (Component/Label).
classNameNexerastringExtra classes, merged last so they win over the defaults.
styleNexeraCSSPropertiesInline style.
isDisabledReact AriabooleanWhether the tab is disabled.
aria-labelReact AriastringDefines a string value that labels the current element.
aria-labelledbyReact AriastringIdentifies the element (or elements) that labels the current element.
aria-describedbyReact AriastringIdentifies the element (or elements) that describes the object.
hrefReact AriastringA URL to link to. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href).
hrefLangReact AriastringHints at the human language of the linked URL. See[MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#hreflang).
targetReact AriaHTMLAttributeAnchorTargetThe target window for the link. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target).
relReact AriastringThe relationship between the linked resource and the current page. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel).
downloadReact Ariastring | booleanCauses the browser to download the linked URL. A string may be provided to suggest a file name. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download).
pingReact AriastringA space-separated list of URLs to ping when the link is followed. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#ping).
referrerPolicyReact Aria"" | "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url"How much of the referrer to send when following the link. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#referrerpolicy).
routerOptionsReact ArianeverOptions for the configured client side router.
onPressReact Aria(e: PressEvent) => voidHandler that is called when the press is released over the target.
onPressStartReact Aria(e: PressEvent) => voidHandler that is called when a press interaction starts.
onPressEndReact Aria(e: PressEvent) => voidHandler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
onPressChangeReact Aria(isPressed: boolean) => voidHandler that is called when the press state changes.
onPressUpReact Aria(e: PressEvent) => voidHandler that is called when a press is released over the target, regardless of whether it started on the target or not.
* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.
Accessible by default.
Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.
WCAG 2.2 evidence
6 direct · 4 supporting- 1.1.1Non-text ContentLevel A · tested directly
- 1.3.1Info and RelationshipsLevel A · tested directly
- 1.3.2Meaningful SequenceLevel A · tested directly
- 1.4.1Use of ColorLevel A · supporting test
- 1.4.4Resize TextLevel AA · supporting test
- 2.1.1KeyboardLevel A · tested directly
- 2.4.7Focus VisibleLevel AA · tested directly
- 2.4.11Focus Not Obscured (Minimum)Level AA · supporting test
- 2.5.8Target Size (Minimum)Level AA · supporting test
- 4.1.2Name, Role, ValueLevel A · tested directly
Fits any width.
Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.
Styling hooks
Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.
data-disableddata-focus-visibledata-hovereddata-selected
<Tab className="data-disabled:opacity-90 shadow-sm" />Used in blocks
- Top bar with tabsApp shells and navigation
- Notification centreMessaging and collaboration
- Approvals inboxWork and projects
Related components
- BreadcrumbShows where the current page sits in the hierarchy and links back to each level.
- BreadcrumbItemOne level of a `Breadcrumb` trail; use it only inside `Breadcrumb`.
- CursorPagerA previous and next pair for data without stable page numbers, such as an activity log or a cursor API.
- FABThe main action of a mobile screen: a floating button with a `nav/active-bg` fill and a large shadow.
- FeedStatusThe status line at the bottom of an infinite feed or a lazy list: "Loading more", "You have reached the end" or "Could not load more" with a retry action.
- JumpToPageA small "Go to page [48] of 120" control for long paged lists.
- NavigationBarThe bottom bar of a mobile layout: a named `nav` landmark with a list of three to five `NavItem`s.
- NavItemOne destination or action of a `NavigationBar`.