Components · Navigation
Tabs
A row of tabs for the sections of one page, each with its own content; the selected tab is a yellow sticker, and the row scrolls when the tabs don't fit.
import { Tabs } from "@botiverse/raft-ui";Tabs switch between the sections of one page, each with its own content: an agent's profile, activity and workspace, for example. The selected tab is a yellow sticker, the same "you are here" as a sidebar row or a segmented control. When the tabs don't fit, the row scrolls sideways.
When to use
A place with several kinds of content, such as an agent, shows them as one row of sticker tabs under its header (Navigation). A channel's tasks and files are not tabs: they are side sections beside the conversation. Only where a column is too short for two stacked sections, or the sections cover the panel on a phone, does a Tasks / Files row of tabs switch between them. Where a conversation's row can't give every column 160px, the rightmost columns become tabs in their left neighbour's head, in place of its title (The channel's side columns).
Anatomy
Tabs: the root. It holds the selected value and theplacement.TabsList: the row of tabs.TabsTab: one tab, with an optional icon before aTabsLabel.TabsPanel: the content of one tab.SortableTabsListandSortableTabsTab: a row whose tabs people can reorder by dragging.useOrderedTabsrestores a saved order.
Variants
The sticker tab is the default, and the one the product ships: a selected tab says "you are here", like a selected sidebar row or segment, so it takes the same yellow sticker (Navigation). The underline stays a variant. placement puts the row on the top (the default), bottom, left or right of the panels.
Behavior
- When the tabs don't fit, the row scrolls on its own. Tabs never wrap onto a second line and never shrink their text.
- The row shows no scrollbar, and a vertical mouse wheel scrolls it sideways.
- The side that hides tabs fades out over the edge fade, 24px (
mask-fade-x, Edges fade). It was 32px; it now matches every strip that scrolls sideways. - The selected tab always scrolls into view.
- On a touch screen a tab switches when the finger lifts, so a tap that stops a scrolling list still switches (Switching on finger lift).
- In a
SortableTabsList, dragging a tab follows Drag and drop: a lifted copy of the tab follows the hand, the tab stays at 40% until it moves, its slot becomes the dashed place and the other tabs slide apart, and a drop or a cancel glides in 160ms. A mouse picks a tab up after 6px; a finger after a 500ms hold. The lifted copy renders indocument.body(containerto change it), so a drawer's or a dialog's transform doesn't offset it.
Focus
The row clips whatever is drawn past its box (it scrolls, and its edge fade is a mask), so in a sideways row a focused tab's ring lost its top and bottom, and in dark mode the selected sticker's outer edge was cut too (raft-design #1447). So the row keeps room inside its box for what its tabs draw past theirs, and gives it back with a negative margin: the first tab stays on the content's edge, and the row reaches past its column by that much. Put the row where that room beside it is free, as a column's margin is. A panel's tab row (ConversationPanel) has padding of its own, which is the room, so it drops the margin. Whenever you set the row's own padding or width, set its margin too (m-0, or mx-0 / my-0 for the axis you padded), and keep at least the room as padding; otherwise the tabs move by the margin and the ring is clipped again. The ring shows only after keyboard navigation, like every ring (Focus).
- A sticker row keeps 4px on every side, the reach of
focus-ring, so a sticker tab takes the usual ring outside it, the selected one too, outside its ink edge, and the selected sticker's outer edge in dark mode stays whole. Over the 2px between tabs the ring covers the next tab's edge, so the focused tab is raised above it. - An underline tab's text runs to its sides, so its ring (2px, inset, in
foreground) is drawn on a shape of its own: the control's height, centered on the tab, 10px past the text on each side, inradius-control. The selected line stays on the row's edge, under the ring, so a focused selected tab shows both. - A sideways underline row keeps 10px at each end, for the ring of its first and last tab.
- A tab the arrow keys move to scrolls clear of the edge fade, so its ring isn't faded out.
A tab's own controls
When a tab's content has controls of its own (a view switch, filters, search, a sort), they go in one toolbar row at the top of the tab's content, under the tabs. Every tab with controls uses the same row, the one the Tasks page draws (TasksPanelToolbar), so a person who has learned one tab knows where to look in the next:
- The row has its own height and padding, the content margin at its sides and a
line-seambelow it, and it stays pinned while the content scrolls under it. Content never starts flush under the row, and never scrolls up against the tabs. - The search starts at the row's left and fills the line, the filters after it; a SegmentedControl that switches the view goes at its right end. A view switch on the left would sit right under the selected tab, and two yellow stickers stacked one above the other read as the same level. The row gives way as the toolbar over a list does, in at most two lines (Responsive layout).
- A tab with no controls has no row.
Content
- Label tabs with 1 or 2 words in sentence case: Profile, Activity, Workspace (Typography).
- Put a count in its own Space Mono element after the label, never in the label's text.
Accessibility
Tabswraps the Base UI Tabs, which provides the tab list, tab and panel semantics and the arrow keys.- Name the
TabsListafter the place it belongs to:aria-label="launch-week". - Give every icon-only tab an
aria-label. - Sortable tabs are reordered with a pointer, by touch or with the keyboard: Space picks the focused tab up, ArrowLeft and ArrowRight (ArrowUp and ArrowDown on a vertical row) move it, Space drops it and Escape puts it back. Enter selects the focused tab; in a sortable row Space doesn't, it picks the tab up. While a tab is lifted, the arrow keys move it instead of the focus (Drag and drop).
- Each step of a tab's drag is announced by the tab's name (its
aria-labelor its text) and its position in the row, named after theTabsList'saria-label; never by its value. Pass your translations asmessages.
Rules
- Use one row of tabs per screen.
- Make a sticker tab 32px high (34px with a mouse, the control height), with a 44px hit area and 8px of row above and below it, so the selected sticker sits as far from the line above as from the line below. Its width follows its label, and it has no track behind it.
- Make an underline tab 44px high, 20px from the next, with text only.
- Draw a
line-seamunder the row in both variants. When you change the size of the text or the row, check that the selected tab's space above and below is still equal. - Start the first sticker on the content's edge, the same margin as the panel header's first element (Page structure). In dark mode the selected sticker has the die-cut edge like every sticker, so it lines up with the avatar in the header (Dark mode).
API
SortableTabsList
Also takes the attributes of its element.
SortableTabsTab
Also takes the attributes of its element.
Tabs
Also takes the attributes of its element.
TabsLabel
Takes the attributes of its element.
TabsList
Also takes the attributes of its element.
TabsPanel
Also takes the attributes of its element.
TabsTab
Also takes the attributes of its element.
Related
Changes
- 0.105.0 · Design SystemA focus ring where its container clips ([States › Focus](https://raft-design.botiverse.build/foundations/states/#focus), [Elevation › Focus ring](https://raft-design.botiverse.build/foundations/elevation/#focus-ring)): where something around an element clips what is past its box (a row or a list that scrolls, an edge fade,
overflow-hidden), the ring is kept whole. First the container makes room: it keeps the ring's reach inside its box as padding and gives it back with a negative margin, so the ring stays outside the element. Only where the container can't make room is the ring drawn inside the element (inset-ring-2). An element whose content runs to its sides draws the ring on a shape of its own. Changed in this release:TabsList,TabsTab,ConversationPanelTabs. - 0.104.0 · Design SystemTooltips on a touch screen, and who owns a long press ([Tooltip › Touch screens](https://raft-design.botiverse.build/components/tooltip/#touch-screens), [States › Dragging on a touch screen](https://raft-design.botiverse.build/foundations/states/#dragging-on-a-touch-screen)): on a touch screen a tooltip opens on a press and hold, on a disabled button too (
focusableWhenDisabled); a long press belongs to the layer that owns it (a long-press menu, a touch drag, a link), and the tooltip takes it only when nothing else wants it. Changed in this release:TooltipTrigger, and the long-press ownersContextMenuTrigger,SortableTabsTab,SortableComposerAttachmentandTaskDraggable. - 0.81.0 · Fixed
DragLiftrenders the copy indocument.bodyby default: the lifted copy goes through a portal to the body unlesscontainernames another element, ornullkeeps it in place; the portal keeps the theme scope it was rendered in.TaskDragOverlayfollows, asSortableTabsListandSortableComposerAttachmentsalready did. - 0.5.36 · ChangedElegant
Tabsunderline: the bar starts on the 20px line at every width (the first icon lands at 32), and the strip has one source now — the indicator defaults tobg-primary-400and the placement blocks no longer draw a static hairline, so the conversation panel, the agent-details strip and the docs read the same look. Brutal underline: the conversation panel drops its asymmetric first-tabpl-[22px]; the strip sits at 16 and reads centred, as the agent-details strip.