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.
Also 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).
When to use
Anatomy
- The tab: a
TabsTabnamed by the tab's whole name (tabAccessibleName), holding:- its icon (16px), given by
icon; - its title:
prefixandtitlefor an object; for asite, itspageTitle, 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 icon (16px), given by
- Its ×, laid over the tab's end, out of the Tab order.
- The tab's menu:
menu, the items of a ContextMenu.
States
Behavior
sourcesays 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.
- 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.
- 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
menuHandsFocussays the chosen item moved it on. onClosegets the tab'svalue: 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.
pinnedstays 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 (itsdensity); 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.hostgives it astitle: 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
idandaria-controls, and the pane'sPaneBodyrole="tabpanel", thatid's target andaria-labelledbythe tab'sid(Pane). A Tab putsid,aria-controlsandaria-describedbyon itsrole="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
One 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`).
Also takes the attributes of its element.