Raft Design System

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.

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

tabs/compositions/placement

When to use

SituationUse
Sections of one page, each with its own contentTabs
Another view of the same contentSegmentedControl
The steps of a flow, in orderSteps
A product's destinationsAppRail, MobileNav

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 the placement.
  • TabsList: the row of tabs.
  • TabsTab: one tab, with an optional icon before a TabsLabel.
  • TabsPanel: the content of one tab.
  • SortableTabsList and SortableTabsTab: a row whose tabs people can reorder by dragging. useOrderedTabs restores a saved order.

Variants

VariantUse for
variant="default"The sticker tab: the selected tab is a yellow sticker. The default
variant="underline"Many tabs, or a place that already has a lot of color: the selected tab is ink text with a 2px ink line on the row's bottom edge

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 in document.body (container to change it), so a drawer's or a dialog's transform doesn't offset it.
tabs/compositions/sortable

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, in radius-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-seam below 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

  • Tabs wraps the Base UI Tabs, which provides the tab list, tab and panel semantics and the arrow keys.
  • Name the TabsList after 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-label or its text) and its position in the row, named after the TabsList's aria-label; never by its value. Pass your translations as messages.

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-seam under 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

PropTypeDefault
containerWhere the lifted copy renders: `document.body` by default, so a transformed ancestor (a drawer, a dialog) doesn't offset it. `null` renders it in place.Element | DocumentFragment
messagesYour translations of the drag's instructions and announcements. Each step is said by the tab's name (its `aria-label` or text) and its position in the row, named after the list's `aria-label`; never by its value.Partial<DragMessages>
onDragStartA tab was picked up. On a touch screen the long press that armed it may have opened a menu the caller owns: close it here (DS › States › Dragging on a touch screen).((event: BaseUIEvent<DragEvent<HTMLDivElement>>) => void) & ((value: T) => void)
onReorder (required)(value: T[]) => void
value (required)readonly T[]
variantTabsListVariant"default"
activateOnFocusWhether to automatically change the active tab on arrow key focus. Otherwise, tabs will be activated using <kbd>Enter</kbd> or <kbd>Space</kbd> key press.booleanfalse
loopFocusWhether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys.booleantrue
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

SortableTabsTab

PropTypeDefault
value (required)The value of the Tab.any
disabledWhether the Tab is disabled.boolean
nativeButtonWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).booleantrue
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

Tabs

PropTypeDefault
defaultValueT
onValueChange(value: T, eventDetails: BaseTabs.Root.ChangeEventDetails) => void
placementSide of the panels the tab list sits on. `left` and `right` also make the tabs vertical (arrow up / down) unless `orientation` is set.TabsPlacement"top"
valueT
variant"default" | "underline""default"
orientationThe component orientation (layout flow direction).Orientation'horizontal'
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

TabsLabel

Takes the attributes of its element.

TabsList

PropTypeDefault
variantTabsListVariant"default"
activateOnFocusWhether to automatically change the active tab on arrow key focus. Otherwise, tabs will be activated using <kbd>Enter</kbd> or <kbd>Space</kbd> key press.booleanfalse
loopFocusWhether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys.booleantrue
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

TabsPanel

PropTypeDefault
keepMountedWhether to keep the HTML element in the DOM while the panel is hidden.booleanfalse
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)
value (required)The value of the TabPanel. It will be shown when the Tab with the corresponding value is active.any

Also takes the attributes of its element.

TabsTab

PropTypeDefault
value (required)The value of the Tab.any
disabledWhether the Tab is disabled.boolean
nativeButtonWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).booleantrue
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

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 owners ContextMenuTrigger, SortableTabsTab, SortableComposerAttachment and TaskDraggable.
  • 0.81.0 · FixedDragLift renders the copy in document.body by default: the lifted copy goes through a portal to the body unless container names another element, or null keeps it in place; the portal keeps the theme scope it was rendered in. TaskDragOverlay follows, as SortableTabsList and SortableComposerAttachments already did.
  • 0.5.36 · ChangedElegant Tabs underline: 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 to bg-primary-400 and 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-tab pl-[22px]; the strip sits at 16 and reads centred, as the agent-details strip.