Raft Design System

Components · Navigation

Tab

One object's tab in a pane's TabBar — its icon and title, its ×, and a menu that opens as a browser tab's does; pinned, title only, new things, waiting to sign in, a task's reference and a web page's title.

ExperimentalAlso called Object tab, Workspace tab, Editor tab, Browser tab
import { Tab } from "@botiverse/raft-ui/wip";

A Tab is one object open in a pane, in the pane's TabBar: it says what the object is, its icon and its title, and holds none of the object's actions. The front tab's × always shows; a background tab's shows on hover. As in a browser, the tab's menu has no button: it opens on a right-click, a touch hold lifted, or Shift+F10 or the context-menu key. It is built on TabsTab, so the bar is one tablist with roving focus and the arrow keys (Tabs and panes).

tab/compositions/preview

When to use

SituationUse
An object open in a pane beside a conversation: a document, a task, a file, an App, a web pageTab, in a TabBar
The sections of one page, each with its own contentTabs
Another view of the same contentSegmentedControl
What was opened from a list worked through one item at a timeNot a tab: the pane beside it (Tabs and panes)

Anatomy

  • The tab: a TabsTab named by the tab's whole name (tabAccessibleName), holding:
    • its icon (16px), given by icon;
    • its title: prefix and title for an object; for a site, its pageTitle, or while it has none its domain drawn by SiteDomain, after Not secure on http;
    • what is new, a key while it waits to sign in.
  • Its ×, laid over the tab's end, out of the Tab order.
  • The tab's menu: menu, the items of a ContextMenu.

States

StatePropWhat shows
In frontTabBar valueThe selected sticker; the × always shown. The same width as in the back.
In the backThe × on hover.
PinnedpinnedFirst in the bar, its icon alone, centred, no ×. Read as "…, pinned". The workspace tabs don't use it for now.
New thingsunread, unreadDotAn unread count (Badge, accent) for what can be counted; an attention dot (Status, accent) for what can't.
Waiting to sign inwaitingSignInA key after the title until the tab is shown: a page in the back never signs in on its own.
Title onlyTabBar density="compact"In a pane under 280px every tab, in front or not, keeps its title alone, no icon; its × is laid over the title's end.
Draggeddragging, shiftIts place stays at 40% (data-drag-origin); tabs after a drop point slide by TAB_DROP_GAP.
SqueezedsqueezedAnother pane's tab while the bar's pane is maximized, after the bar's divider, dimmed: no ×, never in front; its menu still opens.
MergedTabBar mergedA tab of the column merged into the bar in a narrow window, after its divider: a whole tab, as the bar's own are (data-merged).
Opened againlocatedThe located highlight, once (States).
tab/compositions/title-only
tab/compositions/dragging

Behavior

  • source says where the title and icon come from: app, the App's registered name and icon; site, a web page; object, the app's own object. A web page's tab is named by its page title (pageTitle), as in a browser, on every tab, front or not; only while the page has no title does the tab show its domain (title). The full URL never shows in a tab: it is in the address row.
  • The title and icon come from the object live, so a renamed object or a task's new status shows at once.
  • A task's tab is its reference and its title. In a narrow tab the place gives way first (#launch-week:, dm:@Martin:), and the number stays with the start of the title; a place squeezed to a stub is dropped.
tab/compositions/task-reference
  • A domain, shown while the page has no title, is drawn by SiteDomain and cut at its start, never its end; a page title is cut at its end, as any title is. On http, Not secure goes before whichever the tab shows; a title-only tab (a compact bar) leaves it to the address row.
tab/compositions/site
  • The menu has no button, on any tab, as a browser tab's menu has none. It opens on a right-click (at the pointer), Shift+F10 or the context-menu key (under the tab, its first item highlighted), and a 500ms touch hold lifted without moving (under the tab). A hold that moves is a drag; the menu never opens while the finger is down, unlike other items with a menu (States). When it closes, focus goes back to the tab, unless menuHandsFocus says the chosen item moved it on.
  • onClose gets the tab's value: the ×, Delete or Backspace on the focused tab, and a middle click. A pinned or squeezed tab doesn't close; a merged one does, as any tab of the bar.
  • Choosing a tab never changes a width, its own or another's, as in a browser: a tab is laid out the same in front or not. It shows the same things, keeps the ×'s room whether its × shows or not (a background tab's × shows on hover, in that room), and the front tab keeps the others' weight; only its colours change.
  • The front tab always stays in the bar: the width fit never hides it, and never gives it a width of its own.
  • pinned stays for a later decision: the workspace tabs have no Pin for now, so the shell never passes it (Tabs and panes).
  • TabBar sets each tab's width, which tab is in front (its value) and how much the tabs show (its density); a Tab never sizes itself beyond its caps (200px, 120px title only).

Content

  • The title is the object's own: a document's or a task's title, an App's registered name, a web page's title. Pass a site's host as URL.host gives it as title: it shows only until the page has a title.
  • Write a task's reference as the app writes it: #launch-week:#25, dm:@Martin:#3.
  • Pass translations as messages; the defaults are English (UI writing).

Accessibility

  • Each tab is a role="tab" in the bar's tablist (Tabs); its accessible name and tooltip are what it shows with its states: "#launch-week:#25 Ship the tab bar, 2 new", "Example Docs, pinned" (a page's title; its domain while it has none), "Board, waiting to sign in".
  • ArrowLeft and ArrowRight move between tabs, Enter or Space brings one to the front, Delete or Backspace closes it, Shift+F10 or the context-menu key opens its menu. The × isn't in the Tab order: the keyboard reaches it through the tab (Delete).
  • Closing the focused tab removes it: the app moves focus to the tab that comes to the front.
  • The × is named Close and the tab's name. The menu is named after the tab.
  • The count, the dot and the key are hidden from assistive technology: the tab's name says them.
  • The bar has no tab panels of its own. To link a tab to what it shows, give the Tab an id and aria-controls, and the pane's PaneBody role="tabpanel", that id's target and aria-labelledby the tab's id (Pane). A Tab puts id, aria-controls and aria-describedby on its role="tab" element; its other props go on its wrapper.

Rules

  • Put nothing of the object's on its tab but its icon and title: its actions go in its row's ⋯, a web page's and an App's too. The tab's menu holds only the tab's and its pane's.
  • Give no tab a button for its menu: it opens as a browser tab's does.
  • Never open the menu on a touch hold while the finger is down: it opens on lift, so a hold that moves can be a drag.
  • Name a web page's tab by its page title, its domain only until it has one; never the URL. Which site it is, the address row says, with SiteDomain.

API

Tab

ExperimentalOne tab of a pane's TabBar, built on `TabsTab` inside the bar's `Tabs` › `TabsList` (roving focus, arrow keys, `role="tab"`). It says what the object is, its icon and title, and holds none of the object's actions. TabBar sets its width, and says whether it is in front (the bar's `value`) and how much it shows (the bar's `density`).
PropTypeDefault
draggingThe tab a drag came from: it stays in place at 40%.boolean
icon (required)16px. The App's registered icon, a globe for a site, the object's icon.ReactNode
insecureA `site` over http: Not secure before its title or domain; a title-only tab leaves it to the address row.boolean
locatedA new value each time the tab is opened again and shown in place of a second copy: the located highlight, once (states.md#located).string | number
menuThe tab's menu: `ContextMenu` items for what is done to the tab and its pane. As in a browser it has no button: it opens on right-click, on Shift+F10 or the context-menu key while the tab has focus, and on a touch screen when a 500ms hold ends without moving (a hold that moves is a drag).ReactNode
menuHandsFocusRead once as the menu closes: true when the item chosen moved focus on (a dialog); otherwise focus returns to the tab.() => boolean
messagesPartial<TabMessages>
onCloseCloses the tab, given its `value`: the ×, Delete or Backspace on the focused tab, and a middle click. Not on a pinned tab. One handler can serve every tab of a bar.(value: string) => void
pageTitleA `site`'s page title: the tab's name, as in a browser. Empty while the page has none, and the tab shows the domain. Never the URL.string
pinnedPinned: first in the bar, its icon only, centred, no ×.boolean
prefixBefore the title, in the regular weight: a task's reference (`#launch-week:#25`). In a narrow tab the place gives way first; the number and the start of the title always stay.string
shiftPx the tab slides right while a drop opens a gap before it (`TAB_DROP_GAP`).number
source (required)`app`: the App's registered name and icon; `site`: a web page, named by its `pageTitle`, or by its domain (drawn with SiteDomain) while it has none; `object`: the app's own object (a document, a task, a file).TabSource
squeezedAnother pane's tab while the bar's pane is maximized (the bar's `squeezed`, after its divider): dimmed, no ×, given only the room the bar's own tabs leave (then listed in All tabs), never the front tab; choosing it is the app's, to restore with. Its `menu` still opens. A tab merged into the bar in a narrow window is not squeezed: it is a whole tab, in the bar's `merged`.boolean
title (required)The App's name, the site's host (`URL.host`), or the object's title. A `site` shows it only while it has no `pageTitle`.string
unreadNew things that can be counted (new replies, new comments): a count after the title.number
unreadDotA new thing that can't be counted (a new version): an attention dot after the title.boolean
value (required)The tab's value in its `Tabs` (the tab's id). It is in front when it is its TabBar's `value`.string
waitingSignInThe page asked to sign in while hidden: a key after the title until the tab is shown.boolean

Also takes the attributes of its element.