OverviewInstallationMigrating to 1.0Themes and layersKanok designCustomizingIconsForms and validationFrameworksUsing with AIButtonText inputText areaNumber inputSearchSelectDropdownComboboxMulti-selectCheckboxRadio buttonToggleDate pickerTime pickerSliderFile uploaderModalSide panelTearsheetNotificationToastTooltipDefinition tooltipPopoverToggletipMenuData tableStructured listPaginationContained listTree viewTabsBreadcrumbLinkPagination navContent switcherAccordionProgress indicatorUI shellTagTileCardProduct cardCode snippetCopy buttonUser avatarTruncated textListLoadingInline loadingProgress barSkeletonBadge indicatorStatus indicatorGridHeadingLayerAction setPage headerBig numberEdit in placeIntroductionText inputText areaNumber inputSearchSelectDropdownComboboxMulti-selectCheckboxRadio buttonToggleDate pickerTime pickerSliderFile uploaderTabsPagination navContent switcherTooltipDefinition tooltipPopoverMenuAccordionProgress indicatorUI shellModalSide panelTearsheetNotificationToastData tableStructured listPaginationTree viewCode snippetCopy buttonTruncated textLoadingTagCardProduct cardEdit in place
Tabs
Tabs split related content into views on one page. One tab is selected at a time, and only its panel shows. A disabled tab stays in the strip but can't be chosen.
OverviewPartiesHistoryArchiveSummary of the contract terms.Signers and counterparties.Every change, newest first.Archived copies.
HTMLReactReact + Tailwind<ui-tabslabel="Contract details">
<ui-tabpanel="overview">Overview</ui-tab>
<ui-tabpanel="parties">Parties</ui-tab>
<ui-tabpanel="history">History</ui-tab>
<ui-tabpanel="archive"disabled>Archive</ui-tab>
<ui-tab-panelname="overview">Summary of the contract terms.</ui-tab-panel>
<ui-tab-panelname="parties">Signers and counterparties.</ui-tab-panel>
<ui-tab-panelname="history">Every change, newest first.</ui-tab-panel>
<ui-tab-panelname="archive">Archived copies.</ui-tab-panel>
</ui-tabs><UiTabslabel="Contract details">
<UiTabpanel="overview">Overview</UiTab>
<UiTabpanel="parties">Parties</UiTab>
<UiTabpanel="history">History</UiTab>
<UiTabpanel="archive"disabled>Archive</UiTab>
<UiTabPanelname="overview">Summary of the contract terms.</UiTabPanel>
<UiTabPanelname="parties">Signers and counterparties.</UiTabPanel>
<UiTabPanelname="history">Every change, newest first.</UiTabPanel>
<UiTabPanelname="archive">Archived copies.</UiTabPanel>
</UiTabs><Tabs>
<TabListlabel="Contract details">
<Tabvalue="overview">Overview</Tab>
<Tabvalue="parties">Parties</Tab>
<Tabvalue="history">History</Tab>
<Tabvalue="archive"disabled>Archive</Tab>
</TabList>
<TabPanelvalue="overview">Summary of the contract terms.</TabPanel>
<TabPanelvalue="parties">Signers and counterparties.</TabPanel>
<TabPanelvalue="history">Every change, newest first.</TabPanel>
<TabPanelvalue="archive">Archived copies.</TabPanel>
</Tabs>
Installation
npmshadcn · Web componentshadcn · React + TailwindManualnpminstall@purpurabog/uinpxshadcn@4add@kanok-ui/tabsnpxshadcn@4add@kanok-ui/tw-tabs# Web component# 1. Install the dependenciesnpminstalllit@^3.3.0# 2. Copy each file's "content" from# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/tabs.json# to its target:# components/ui/primitives/tabs/tab-panel.ts# components/ui/primitives/tabs/tab.ts# components/ui/primitives/tabs/tabs-skeleton.ts# components/ui/primitives/tabs/tabs.styles.ts# components/ui/primitives/tabs/tabs.ts# 3. Do the same for the items it needs (registry/<name>.json):# core-roving, layer, shared-element, shared-field, shared-localize, shared-skeleton, tooltip, tokens# React + Tailwind# 1. Install the dependenciesnpminstall@purpurabog/ui@^2.3.0# 2. Copy each file's "content" from# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/tw-tabs.json# to its target:# components/ui/react-tw/tabs.tsx# 3. Do the same for the items it needs (registry/<name>.json):# tw-i18n, tw-layer, tw-theme, tw-tooltip, tw-utils
npm gives you every component from the package. shadcn copies the source into your app instead: a copy pinned to this version that you can change. The shadcn commands need the @kanok-ui registry in your components.json once, see Installation.
Use it
Each <ui-tab panel> matches the name of a <ui-tab-panel>. Tabs and panels may come in any order in the markup: the tabs go into the strip by themselves. label names the strip for screen readers.
HTMLReactReact + Tailwind<scripttype="module">import'@purpurabog/ui/tabs';</script>
<ui-tabslabel="Contract details">
<ui-tabpanel="overview">Overview</ui-tab>
<ui-tabpanel="parties">Parties</ui-tab>
<ui-tab-panelname="overview">Summary of the contract terms.</ui-tab-panel>
<ui-tab-panelname="parties">Signers and counterparties.</ui-tab-panel>
</ui-tabs>import { UiTabs, UiTab, UiTabPanel } from'@purpurabog/ui/react';
<UiTabslabel="Contract details">
<UiTabpanel="overview">Overview</UiTab>
<UiTabpanel="parties">Parties</UiTab>
<UiTabPanelname="overview">Summary of the contract terms.</UiTabPanel>
<UiTabPanelname="parties">Signers and counterparties.</UiTabPanel>
</UiTabs>import { Tabs, TabList, Tab, TabPanel } from'@/components/ui/react-tw/tabs';
<Tabs>
<TabListlabel="Contract details">
<Tabvalue="overview">Overview</Tab>
<Tabvalue="parties">Parties</Tab>
</TabList>
<TabPanelvalue="overview">Summary of the contract terms.</TabPanel>
<TabPanelvalue="parties">Signers and counterparties.</TabPanel>
</Tabs>
In React + Tailwind, the Tabs sit in a TabList (it takes label), and a Tab and its TabPanel share a value.
Tabs, content switcher or accordion?
Component
Use it when
Tabs
The views are sections of one item (a contract's terms, parties, history) and the reader looks at one at a time.
A long page of sections the reader may open several of, or read top to bottom.
Starting tab and changes
value is the name of the panel that shows; left out, the first enabled tab is selected. ui-tab-change fires after the user selects another tab, with the panel's name in detail.name.
DraftLegal reviewSigningThe requester fills in the contract form.Legal checks the terms and the counterparty.Both parties sign, and the contract is filed.
Selected:
HTMLReactReact + Tailwind<ui-tabsid="tabs-start"label="Approval steps"value="review">
<ui-tabpanel="draft">Draft</ui-tab>
<ui-tabpanel="review">Legal review</ui-tab>
<ui-tabpanel="sign">Signing</ui-tab>
<ui-tab-panelname="draft">The requester fills in the contract form.</ui-tab-panel>
<ui-tab-panelname="review">Legal checks the terms and the counterparty.</ui-tab-panel>
<ui-tab-panelname="sign">Both parties sign, and the contract is filed.</ui-tab-panel>
</ui-tabs>
<p>Selected: <outputid="tabs-start-out"></output></p>
<scripttype="module">
const tabs = document.getElementById('tabs-start');
const out = document.getElementById('tabs-start-out');
out.value = tabs.value;
tabs.addEventListener('ui-tab-change', (event) => (out.value = event.detail.name));
</script>const [step, setStep] =useState('review');
<UiTabslabel="Approval steps"value={step} onUiTabChange={(e) =>setStep(e.detail.name)}>
<UiTabpanel="draft">Draft</UiTab>
<UiTabpanel="review">Legal review</UiTab>
<UiTabpanel="sign">Signing</UiTab>
<UiTabPanelname="draft">The requester fills in the contract form.</UiTabPanel>
<UiTabPanelname="review">Legal checks the terms and the counterparty.</UiTabPanel>
<UiTabPanelname="sign">Both parties sign, and the contract is filed.</UiTabPanel>
</UiTabs>
<p>Selected: <output>{step}</output></p>const [step, setStep] =useState('review');
<Tabsvalue={step} onValueChange={setStep}>
<TabListlabel="Approval steps">
<Tabvalue="draft">Draft</Tab>
<Tabvalue="review">Legal review</Tab>
<Tabvalue="sign">Signing</Tab>
</TabList>
<TabPanelvalue="draft">The requester fills in the contract form.</TabPanel>
<TabPanelvalue="review">Legal checks the terms and the counterparty.</TabPanel>
<TabPanelvalue="sign">Both parties sign, and the contract is filed.</TabPanel>
</Tabs>
<p>Selected: <output>{step}</output></p>
React + Tailwind also takes defaultValue for an uncontrolled start.
Contained
type="contained" draws 48px tabs on a grey strip with dividers. The selected tab sits on the layer with a blue top edge, and the panels sit on the layer too. Use it where the tabs head a card or a section of their own.
OverviewPartiesHistoryArchiveSummary of the contract terms.Signers and counterparties.Every change, newest first.Archived copies.
HTMLReactReact + Tailwind<ui-tabslabel="Contract details"type="contained">
<ui-tabpanel="overview">Overview</ui-tab>
<ui-tabpanel="parties">Parties</ui-tab>
<ui-tabpanel="history">History</ui-tab>
<ui-tabpanel="archive"disabled>Archive</ui-tab>
<ui-tab-panelname="overview">Summary of the contract terms.</ui-tab-panel>
<ui-tab-panelname="parties">Signers and counterparties.</ui-tab-panel>
<ui-tab-panelname="history">Every change, newest first.</ui-tab-panel>
<ui-tab-panelname="archive">Archived copies.</ui-tab-panel>
</ui-tabs><UiTabslabel="Contract details"type="contained">
<UiTabpanel="overview">Overview</UiTab>
<UiTabpanel="parties">Parties</UiTab>
<UiTabpanel="history">History</UiTab>
<UiTabpanel="archive"disabled>Archive</UiTab>
<UiTabPanelname="overview">Summary of the contract terms.</UiTabPanel>
…
</UiTabs><Tabstype="contained">
<TabListlabel="Contract details">
<Tabvalue="overview">Overview</Tab>
<Tabvalue="parties">Parties</Tab>
<Tabvalue="history">History</Tab>
<Tabvalue="archive"disabled>Archive</Tab>
</TabList>
<TabPanelvalue="overview">Summary of the contract terms.</TabPanel>
…
</Tabs>
Full width
With type="contained", full-width (fullWidth) shares the strip in equal columns. A label that doesn't fit ends in an ellipsis.
Case detailsPartiesAttachments and supporting evidence for the hearingHistoryCase number, court and filing date.Plaintiffs, defendants and their lawyers.Documents filed with the case.Every hearing, newest first.
HTMLReactReact + Tailwind<ui-tabslabel="Case sections"type="contained"full-width>
<ui-tabpanel="case">Case details</ui-tab>
<ui-tabpanel="parties">Parties</ui-tab>
<ui-tabpanel="evidence">Attachments and supporting evidence for the hearing</ui-tab>
<ui-tabpanel="history">History</ui-tab>
<ui-tab-panelname="case">Case number, court and filing date.</ui-tab-panel>
<ui-tab-panelname="parties">Plaintiffs, defendants and their lawyers.</ui-tab-panel>
<ui-tab-panelname="evidence">Documents filed with the case.</ui-tab-panel>
<ui-tab-panelname="history">Every hearing, newest first.</ui-tab-panel>
</ui-tabs><UiTabslabel="Case sections"type="contained"fullWidth>
<UiTabpanel="case">Case details</UiTab>
<UiTabpanel="parties">Parties</UiTab>
<UiTabpanel="evidence">Attachments and supporting evidence for the hearing</UiTab>
<UiTabpanel="history">History</UiTab>
…
</UiTabs><Tabstype="contained"fullWidth>
<TabListlabel="Case sections">
<Tabvalue="case">Case details</Tab>
<Tabvalue="parties">Parties</Tab>
<Tabvalue="evidence">Attachments and supporting evidence for the hearing</Tab>
<Tabvalue="history">History</Tab>
</TabList>
…
</Tabs>
Sizes
size: sm 32px, md 40px (the line default), lg 48px (the contained default), xl 64px (contained only; line tabs stop at 48px).
On contained tabs, secondary-label (secondaryLabel) adds a second, smaller line, such as a count. One secondary label makes every tab in the strip 64px tall.
NewIn reviewSignedAllContracts waiting for a reviewer.Contracts a reviewer has opened.Contracts both parties signed.Every contract.
HTMLReactReact + Tailwind<ui-tabslabel="Contract review"type="contained">
<ui-tabpanel="new"secondary-label="(12)">New</ui-tab>
<ui-tabpanel="review"secondary-label="(4)">In review</ui-tab>
<ui-tabpanel="signed"secondary-label="(0)"disabled>Signed</ui-tab>
<ui-tabpanel="all">All</ui-tab>
<ui-tab-panelname="new">Contracts waiting for a reviewer.</ui-tab-panel>
<ui-tab-panelname="review">Contracts a reviewer has opened.</ui-tab-panel>
<ui-tab-panelname="signed">Contracts both parties signed.</ui-tab-panel>
<ui-tab-panelname="all">Every contract.</ui-tab-panel>
</ui-tabs><UiTabslabel="Contract review"type="contained">
<UiTabpanel="new"secondaryLabel="(12)">New</UiTab>
<UiTabpanel="review"secondaryLabel="(4)">In review</UiTab>
<UiTabpanel="signed"secondaryLabel="(0)"disabled>Signed</UiTab>
<UiTabpanel="all">All</UiTab>
…
</UiTabs><Tabstype="contained">
<TabListlabel="Contract review">
<Tabvalue="new"secondaryLabel="(12)">New</Tab>
<Tabvalue="review"secondaryLabel="(4)">In review</Tab>
<Tabvalue="signed"secondaryLabel="(0)"disabled>Signed</Tab>
<Tabvalue="all">All</Tab>
</TabList>
…
</Tabs>
Icon only
icon-only (iconOnly) shows just the icon in a square tab. label is then required: it names the tab and shows as its tooltip on hover and on keyboard focus. With size="lg" the icons grow to 20px.
The signed PDF and its pages.Who signed, and when.Every change, newest first.
By default the arrow keys select as they move (activation="automatic"). With activation="manual", the arrows only move focus, and Enter or Space selects. Use it when a panel is slow to render or loads data.
This monthThis quarterThis yearFocus a tab, move with the arrow keys, then press Enter or Space.The quarter's report loads only when you choose it.The year's report loads only when you choose it.
HTMLReactReact + Tailwind<ui-tabslabel="Reports"activation="manual">
<ui-tabpanel="month">This month</ui-tab>
<ui-tabpanel="quarter">This quarter</ui-tab>
<ui-tabpanel="year">This year</ui-tab>
<ui-tab-panelname="month">Focus a tab, move with the arrow keys, then press Enter or Space.</ui-tab-panel>
<ui-tab-panelname="quarter">The quarter's report loads only when you choose it.</ui-tab-panel>
<ui-tab-panelname="year">The year's report loads only when you choose it.</ui-tab-panel>
</ui-tabs><UiTabslabel="Reports"activation="manual">
<UiTabpanel="month">This month</UiTab>
<UiTabpanel="quarter">This quarter</UiTab>
<UiTabpanel="year">This year</UiTab>
…
</UiTabs><Tabsactivation="manual">
<TabListlabel="Reports">
<Tabvalue="month">This month</Tab>
<Tabvalue="quarter">This quarter</Tab>
<Tabvalue="year">This year</Tab>
</TabList>
…
</Tabs>
An action at the end of the strip
The end slot (the end prop of TabList in React + Tailwind) puts content after the tabs, on the strip's line, for example a ghost button that adds a section.
TermsPaymentAnnexAdd sectionThe terms both parties agreed to.Instalments and due dates.Extra documents.
ui-tab-before-change fires before the selection moves, with detail.name (the new tab) and detail.previous. Call preventDefault() to keep the current tab, for example while a form in it has unsaved changes. In React + Tailwind, keep value as it is in onValueChange.
FormPreviewEdit the contract here.The contract as the counterparty will see it.
HTMLReactReact + Tailwind<ui-checkboxid="tabs-dirty"label="The contract form has unsaved changes"checked></ui-checkbox>
<ui-tabsid="tabs-guard"label="Contract">
<ui-tabpanel="form">Form</ui-tab>
<ui-tabpanel="preview">Preview</ui-tab>
<ui-tab-panelname="form">Edit the contract here.</ui-tab-panel>
<ui-tab-panelname="preview">The contract as the counterparty will see it.</ui-tab-panel>
</ui-tabs>
<p><outputid="tabs-guard-out"></output></p>
<scripttype="module">
const dirty = document.getElementById('tabs-dirty');
const tabs = document.getElementById('tabs-guard');
const out = document.getElementById('tabs-guard-out');
tabs.addEventListener('ui-tab-before-change', (event) => {
out.value ='';
if (!dirty.checked) return;
event.preventDefault();
out.value =`Save the form before you open "${event.detail.name}".`;
});
</script>importtype { UiCheckbox as CheckboxElement } from'@purpurabog/ui';
const [dirty, setDirty] =useState(true);
const [message, setMessage] =useState('');
<UiCheckboxlabel="The contract form has unsaved changes"checked={dirty} onChange={(e) =>setDirty((e.target asCheckboxElement).checked)} />
<UiTabslabel="Contract"onUiTabBeforeChange={(e) => {
setMessage(dirty ?`Save the form before you open "${e.detail.name}".`:'');
if (dirty) e.preventDefault();
}}
>
<UiTabpanel="form">Form</UiTab>
<UiTabpanel="preview">Preview</UiTab>
…
</UiTabs>
<p><output>{message}</output></p>// dirty and message as in Reactconst [tab, setTab] =useState('form');
<Checkboxlabel="The contract form has unsaved changes"checked={dirty} onChange={(e) =>setDirty(e.target.checked)} />
<Tabsvalue={tab}
onValueChange={(next) => {
setMessage(dirty ?`Save the form before you open "${next}".`:'');
if (!dirty) setTab(next);
}}
>
<TabListlabel="Contract">
<Tabvalue="form">Form</Tab>
<Tabvalue="preview">Preview</Tab>
</TabList>
…
</Tabs>
<p><output>{message}</output></p>
Dismissable tabs
dismissable gives every tab a close button, and Delete closes the focused tab. The tab first fires a cancelable ui-request-close (detail.name); unless you prevent it, the tab is hidden and fires ui-close. A closed selected tab passes the selection to the first enabled tab, and focus moves to the tab now in its place. Not with vertical.
In React + Tailwind, onTabCloseRequest gets the tab's value: remove that tab from your list to close it.
Contract.pdfMemo.docxNotesArchiveThe × or Delete on the focused tab closes it.The legal team's memo.Your own notes.Archived copies.
vertical puts the tabs in a column beside the panels once the window is wider than 672px (42rem); on a narrower window they become contained tabs in a row. Labels wrap to two lines, then end in an ellipsis. height fixes the height: the tab list and the panels then scroll inside it.
ProfileApproval rules for contracts above the department's limitNotificationsSignaturesRetentionAudit logWho approves a contract, by amount.Email and in-app alerts.Your saved signature.How long signed copies are kept.Who changed what.
HTMLReactReact + Tailwind<ui-tabslabel="Settings"verticalheight="320px">
<ui-tabpanel="profile">Profile</ui-tab>
<ui-tabpanel="approvals">Approval rules for contracts above the department's limit</ui-tab>
<ui-tabpanel="notifications">Notifications</ui-tab>
<ui-tabpanel="signatures">Signatures</ui-tab>
<ui-tabpanel="retention">Retention</ui-tab>
<ui-tabpanel="audit"disabled>Audit log</ui-tab>
<ui-tab-panelname="profile"><ui-text-inputlabel="Display name"value="Somchai K."></ui-text-input></ui-tab-panel>
<ui-tab-panelname="approvals">Who approves a contract, by amount.</ui-tab-panel>
<ui-tab-panelname="notifications">Email and in-app alerts.</ui-tab-panel>
<ui-tab-panelname="signatures">Your saved signature.</ui-tab-panel>
<ui-tab-panelname="retention">How long signed copies are kept.</ui-tab-panel>
<ui-tab-panelname="audit">Who changed what.</ui-tab-panel>
</ui-tabs><UiTabslabel="Settings"verticalheight="320px">
<UiTabpanel="profile">Profile</UiTab>
<UiTabpanel="approvals">Approval rules for contracts above the department's limit</UiTab>
<UiTabpanel="notifications">Notifications</UiTab>
…
<UiTabPanelname="profile"><UiTextInputlabel="Display name"value="Somchai K." /></UiTabPanel>
…
</UiTabs><Tabsverticalheight="320px">
<TabListlabel="Settings">
<Tabvalue="profile">Profile</Tab>
<Tabvalue="approvals">Approval rules for contracts above the department's limit</Tab>
<Tabvalue="notifications">Notifications</Tab>
…
</TabList>
<TabPanelvalue="profile"><TextInputlabel="Display name"defaultValue="Somchai K." /></TabPanel>
…
</Tabs>
In the column, ↑ and ↓ move between the tabs, and the panels sit one layer up, so their fields keep their contrast.
Many tabs
When the tabs don't fit, the strip scrolls. Previous and next buttons appear at its ends for the mouse; keyboard users have the arrow keys, so the buttons are no Tab stops and are hidden from screen readers.
JanuaryFebruaryMarchAprilMayJuneJulyAugustContracts signed in January.Contracts signed in February.Contracts signed in March.Contracts signed in April.Contracts signed in May.Contracts signed in June.Contracts signed in July.Contracts signed in August.
HTMLReactReact + Tailwind<ui-tabslabel="Months"style="max-width: 480px">
<ui-tabpanel="jan">January</ui-tab>
<ui-tabpanel="feb">February</ui-tab>
<ui-tabpanel="mar">March</ui-tab>
<ui-tabpanel="apr">April</ui-tab>
<ui-tabpanel="may">May</ui-tab>
<ui-tabpanel="jun">June</ui-tab>
<ui-tabpanel="jul">July</ui-tab>
<ui-tabpanel="aug">August</ui-tab>
<ui-tab-panelname="jan">Contracts signed in January.</ui-tab-panel>
<ui-tab-panelname="feb">Contracts signed in February.</ui-tab-panel>
<ui-tab-panelname="mar">Contracts signed in March.</ui-tab-panel>
<ui-tab-panelname="apr">Contracts signed in April.</ui-tab-panel>
<ui-tab-panelname="may">Contracts signed in May.</ui-tab-panel>
<ui-tab-panelname="jun">Contracts signed in June.</ui-tab-panel>
<ui-tab-panelname="jul">Contracts signed in July.</ui-tab-panel>
<ui-tab-panelname="aug">Contracts signed in August.</ui-tab-panel>
</ui-tabs>// months = [{ value: 'jan', label: 'January' }, …]
<UiTabslabel="Months"style={{ maxWidth:480 }}>
{months.map((m) => <UiTabkey={m.value} panel={m.value}>{m.label}</UiTab>)}
{months.map((m) => <UiTabPanelkey={m.value} name={m.value}>Contracts signed in {m.label}.</UiTabPanel>)}
</UiTabs>// months = [{ value: 'jan', label: 'January' }, …]
<TabsclassName="max-w-[480px]">
<TabListlabel="Months">
{months.map((m) => <Tabkey={m.value} value={m.value}>{m.label}</Tab>)}
</TabList>
{months.map((m) => <TabPanelkey={m.value} value={m.value}>Contracts signed in {m.label}.</TabPanel>)}
</Tabs>
Skeleton
While the page loads, ui-tabs-skeleton stands in for the strip: tabs bars of 160 × 40px (5 by default). It is hidden from screen readers.
On the web component, import it from @purpurabog/ui/tabs-skeleton.
Accessibility
The strip is a tablist named by label; each tab is a tab with aria-selected and aria-controls, and each panel a tabpanel labelled by its tab.
One Tab stop: Tab reaches the selected tab, then moves into the panel. ← and → move between tabs and wrap (↑ and ↓ in a vertical column); Home and End jump to the first and last. Disabled tabs are skipped.
A panel with nothing focusable inside becomes a Tab stop itself, so keyboard users can reach and scroll its text.
Icon-only tabs need label: it is the tab's name and its tooltip.
In dismissable tabs the close button is hidden from screen readers; each tab announces Delete as its shortcut (aria-keyshortcuts).
Unstyled React parts with the same behaviour: Headless Tabs.
API
Generated from the package. In React, pass a property as a prop of the same name; events are props too (the React column).
<ui-tabs> · React UiTabs
Attributes
Attribute
Property
Type
Default
Description
value
value
string
''
Name of the active panel. Defaults to the first enabled tab.
label
label
string
''
Accessible name for the tab strip, e.g. "Product details".
activation
activation
TabsActivation
'automatic'
automatic (Carbon's name; auto is still accepted) or manual.
type
type
TabsType
'line'
line (default) or contained (Carbon cds-tabs type="contained").
size
size
TabsSize | undefined
Tab height (Carbon size): sm 32px, md 40px, lg 48px, xl 64px (contained only); unset = md for line, lg for contained.
full-width
fullWidth
boolean
false
With type="contained": the tabs share the full width in equal columns (Carbon full-width / fullWidth).
vertical
vertical
boolean
false
Carbon TabsVertical: the tabs in a column beside the panels from md up (contained tabs in a row below).
height
height
string
''
A fixed height for vertical tabs (Carbon height), e.g. "400px": the tab list and the panels then scroll.
dismissable
dismissable
boolean
false
A close button on every tab, and Delete closes the focused tab (Carbon dismissable); not with vertical.
Methods
Method
Description
focus(options)
Focus the active tab (the tablist's tab stop).
Events
Event
React
Description
ui-tab-change
onUiTabChange
detail: { name } after the user selects a tab
ui-tab-before-change
onUiTabBeforeChange
Cancelable; detail: { name, previous }. preventDefault() keeps the current tab (e.g. unsaved changes).
ui-request-close
onUiRequestClose
From a <ui-tab> of dismissable tabs (close button or Delete); cancelable; detail: { name }. preventDefault() keeps the tab.
ui-close
onUiClose
From a <ui-tab> after it closed (hidden); detail: { name }
Slots
Slot
Description
nav
<ui-tab> elements (assigned automatically)
(default)
<ui-tab-panel> elements
end
Content at the end of the strip, e.g. an action button
CSS parts
Part
Description
base
The strip holding the tab list and scroll buttons
tablist
The role=tablist container (tabs themselves are light-DOM <ui-tab>s: style the element)
scroll-button
The overflow scroll buttons
end
Wrapper of the end slot
CSS custom properties
Custom property
Default
Description
--ui-tabs-track
box-shadow of the tab strip, for one line under every tab (default none; Kanok: a 1px hairline)
--ui-tabs-gap
Gap between line tabs (default 1px; Kanok: 4px)
--ui-tabs-contained-height
Tab height of type="contained" (default 48px; Kanok: 32px)
flex of the contained strip (default 1, full width; Kanok: hugs the tabs)
--ui-tab-vertical-background
The vertical tab list's fill (default the layer; on <ui-tab> with the other --ui-tab-vertical-* settings)
<ui-tab> · React UiTab
Attributes
Attribute
Property
Type
Default
Description
hidden
panel
panel
string
''
selected
selected
boolean
false
disabled
disabled
boolean
false
Disables the control; a disabled <fieldset> ancestor does the same.
secondary-label
secondaryLabel
string
''
A second line under the label (Carbon secondaryLabel); contained tabs only.
icon-only
iconOnly
boolean
false
Only the icon slot shows (Carbon IconTab); label names the tab and is its tooltip.
label
label
string
''
Accessible name and tooltip of an icon-only tab — required with it.
Events
Event
React
Description
ui-request-close
onUiRequestClose
Dismissable tabs: its close button or Delete; cancelable; detail: { name } (its panel)
ui-close
onUiClose
Dismissable tabs: after it closed (now hidden); detail: { name }
Slots
Slot
Description
(default)
Tab label
icon
A 16px icon (20px in icon-only tabs of size="lg"), coloured like the label
CSS parts
Part
Description
secondary-label
The second line of a contained tab
close-button
The close button of a dismissable tab (no tab stop: Delete closes the focused tab)
tooltip
The <ui-tooltip> of an icon-only tab
CSS custom properties
Custom property
Default
Description
--ui-tab-line
The underline of every tab (default 2px solid --ui-hairline; Kanok: transparent, the strip draws one line)
--ui-tab-selected-line
The selected tab's mark (default --ui-border-interactive, as in Kanok)
--ui-tab-hover-line
Underline colour on hover (default --ui-ink-subtle)
--ui-tab-disabled-line
Underline colour when disabled (default --ui-hairline)
--ui-tab-background
Fill of a line tab (default --ui-canvas; Kanok: transparent)
--ui-tab-contained-background
/ --ui-tab-contained-hover / --ui-tab-contained-selected - Fills of a contained tab at rest, hovered and selected (Carbon: layer-accent, its hover, the layer)
--ui-tab-contained-selected-shadow
box-shadow of the selected contained tab (default: a 2px top bar in --ui-tab-selected-line)
--ui-tab-contained-radius
Corner radius of a contained tab (default 0; Kanok: 6px)
--ui-tab-contained-divider
The 1px line between contained tabs (default --ui-hairline-strong; Kanok: none)
--ui-tab-focus-radius
Corner radius of the focus ring (default 0; Kanok: 6px)
--ui-tab-focus-offset
/ --ui-tab-contained-focus-offset - Where the focus ring sits, line and contained tabs (default -2px, over the selected underline; Kanok: -5px, clear of it, and 1px around the chip)
--ui-tab-vertical-background
/ --ui-tab-vertical-selected / --ui-tab-vertical-bar / --ui-tab-vertical-hover-bar / --ui-tab-vertical-divider / --ui-tab-vertical-inset / --ui-tab-vertical-radius - Vertical tabs: fill, the chosen tab's fill, the side bars, the rule between tabs, inset and corners (default Carbon's layer fill with bars and rules; Kanok: inset rounded rows, the chosen one tinted)
--ui-tab-vertical-mark
The chosen vertical tab's 3px start bar (default --ui-tab-selected-line; Kanok: none, the tint alone)
--ui-icon-control-radius
Corners of its small icon buttons, their hover fill and ring (default 0; Kanok: round)