Skip to main content

Tab

Usage

Definition

Tabs organize content within a category in a horizontal menu of logical subsections.

Each tab within a group contains a distinct subsection of content.

Common Characteristics

All tabs are presented horizontally and have ALL-CAPS labels. All tabs have a separator that spans the width of the content area governed by the tabs. Tabs have these states: selected, active, hover/tap, and focused. A Tab with no content must have explanatory text rather than left blank.

Usage Guidelines

The left-most tab is always pre-selected by default. Content within tabs must be peers related to the same parent category/topic/item. If necessary, tabs can scroll horizontally above the content they govern.

<SandboxDemo>
<div className="container bg-white">
<div className="row">
<div className="col-12">
<Tabs
color="light"
data={Data.TabDataUsage}
activeIndex={0}
/>
</div>
</div>
</div>
</SandboxDemo>

Tabs can scroll above the content if needed. Tabs with no content must have explanatory text. Click the second tab for an example.

Design

States

Tabs have these states: selected, active, hover/tap, and focused.

Tabs are left aligned with a visual separator that spans the width of the content governed by the tabs.

SCSS

Modifiers

NameDescription
tab-light-bkgTabs on a Light Background
tab-dark-bkgTabs on a Dark Background
tab-icon-light-bkgIcon Tab Bar (TOP) on a Light Background
tab-icon-dark-bkgIcon Tab Bar (TOP) on a Dark Background
tab-icon-light-bkg-bottomIcon Tab Bar (BOTTOM) on a Light Background
tab-icon-dark-bkg-bottomIcon Tab Bar (BOTTOM) on a Dark Background

Code

Tabs

Props on the Tabs component will apply to the entire collection. Props on the TabPane will cascade to the Tab component and the underlying Action component.

Tabs can have label and icons

Live Editor
Result
Loading...

Tabs can have either label and icons

Live Editor
Result
Loading...
Live Editor
Result
Loading...

Tabs can set textOnly or iconOnly

Live Editor
Result
Loading...
Live Editor
Result
Loading...

Tab Active

The active tab is set to zero (0) by default and can be set to any tab index.

Live Editor
Result
Loading...

Tab Color

Tabs can be used on light backgrounds

Live Editor
Result
Loading...

Tabs can be used on dark backgrounds

Live Editor
Result
Loading...

Tab Border

Tabs can be used with a border below the tabs

Tabs has a bottom border by default. This is controlled by a boolean property border

Live Editor
Result
Loading...

Tabs can be used without a border below the tabs

This is often used when using a dark background color.

Live Editor
Result
Loading...

Tabs use Buttons under the hood allowing for an href to be provided as a link to an external page.

Live Editor
Result
Loading...

Tab content updates with changes

() => {

const [words, setWords] = React.useState({
nouns: 'cushions',
adjective: 'quirky',
verb: 'flow',
noun3: 'glass',
noun4: 'seahorse',
season: 'fall',
})

const handleWordChange = (e) => {
setWords({
...words,
[e.target.id]: e.target.value
})
}

const say = (what) => <strong>{what}</strong>

return (
<Tabs activeIndex={1} position="bottom">
<TabPane label="Words" icon="list">
<Form>
<Container>
<Row>
<Col>
<Input.Interactive id="nouns"
label="Plural noun"
defaultValue={words.nouns}
onChange={handleWordChange}/>
<Input.Interactive id="noun3"
label="Noun"
defaultValue={words.noun3}
onChange={handleWordChange}/>
<Input.Interactive id="noun4"
label="Noun"
defaultValue={words.noun4}
onChange={handleWordChange}/>
</Col>
<Col>
<Input.Interactive id="adjective"
label="Adjective"
defaultValue={words.adjective}
onChange={handleWordChange}/>
<Input.Interactive id="verb"
label="Verb"
defaultValue={words.verb}
onChange={handleWordChange}/>
<Input.Interactive id="season"
label="Season"
defaultValue={words.season}
onChange={handleWordChange}/>
</Col>
</Row>
</Container>
</Form>
</TabPane>
<TabPane label="Madness" icon="file-text">
<p>
Our {say(words.nouns)} are packed for a hike
in the {say(words.adjective)} mountains!
The higher we {say(words.verb)}, the
smaller the {say(words.noun3)} appear; we
may even see {say(words.noun4)} still on the
ground from last {say(words.season)}.
</p>
</TabPane>
</Tabs>
)}

Tab generated from data prop

<Tabs activeIndex={0} data={[{
label: { icon: 'car' },
content: 'Id sed viris concludaturque, eum facilis rationibus in, qui case munere te. Quo diceret voluptatum id? Id sed sint appetere, ancillae facilisis imperdiet vix ne? Nec in aliquam rationibus scribentur, no per voluptua constituam. Solet aliquando voluptatibus et vel, his id delicata adipiscing. Malis quando per ei.\n\nTe vix vocent vocibus accommodare. Pro eu eripuit democritum elaboraret. Vix inermis philosophia no? Ea libris alienum qui. Ea solet perpetua intellegebat mel, ea his aperiri atomorum.'
}, {
label: { icon: 'bell' },
content: 'Dicam putent pertinax ne vim, ad qui pertinax suavitate, mea eu amet nominati. Te porro dolor eam, at sit paulo corpora! Ne mea modus docendi postulant. Vel solet commodo aliquando an, qui harum oportere mediocrem ne.\n\nId sed probo honestatis, vel in ignota recusabo. An dicunt feugait omittantur est, cu atomorum iudicabit gloriatur eum, pro tale sensibus comprehensam an! Nostrum detracto noluisse qui at, at vivendo mnesarchum nec. Rebum vivendo usu eu, eam partiendo suavitate ex.'
}]} />

Tab generation from data prop can be dynamic

() => {

const [words, setWords] = React.useState({
nouns: 'cushions',
adjective: 'quirky',
verb: 'flow',
noun3: 'glass',
noun4: 'seahorse',
season: 'fall',
})

const handleWordChange = (e) => {
setWords({
...words,
[e.target.id]: e.target.value
})
}

const say = (what) => <strong>{what}</strong>

const data = [
{
label: {
icon: 'list',
text: 'Words',
},
content: <Form>
<Container>
<Row>
<Col>
<Input.Interactive id="nouns"
label="Plural noun"
defaultValue={words.nouns}
onChange={handleWordChange}/>
<Input.Interactive id="noun3"
label="Noun"
defaultValue={words.noun3}
onChange={handleWordChange}/>
<Input.Interactive id="noun4"
label="Noun"
defaultValue={words.noun4}
onChange={handleWordChange}/>
</Col>
<Col>
<Input.Interactive id="adjective"
label="Adjective"
defaultValue={words.adjective}
onChange={handleWordChange}/>
<Input.Interactive id="verb"
label="Verb"
defaultValue={words.verb}
onChange={handleWordChange}/>
<Input.Interactive id="season"
label="Season"
defaultValue={words.season}
onChange={handleWordChange}/>
</Col>
</Row>
</Container>
</Form>
},
{
label: {
icon: 'file-text',
text: 'Madness',
},
content: <p>
Our {say(words.nouns)} are packed for a hike
in the {say(words.adjective)} mountains!
The higher we {say(words.verb)}, the
smaller the {say(words.noun3)} appear; we
may even see {say(words.noun4)} still on the
ground from last {say(words.season)}.
</p>
}
]

return (
<Tabs activeIndex={1} position="bottom" data={data} />
)}

Tab Props

Tabs

NameTypeDefaultDescription
activeIndexnumber0Sets the currently selected tab index (the first tab's index is zero (0))
borderbooltrueToggles the border below the tab buttons
classNamestringString of classnames to add to the Tabs container
color"light" or "dark""light"Sets color state of tabs. Must be either "light" or "dark"
dataarray[dataShape]nullAllows for tab construction via an object
iconOnlyboolSets the tab buttons to display only icon provided
idstringuuid()String used as the id attribute of the Tabs container
onChangefuncCallback function for when the activeIndex is modified. Sends an object containing prevActiveIndex and activeIndex.
size"sm" or "md""md"Sets the display size of the tabs. Must be either "md" or "sm"
textOnlyboolSets the tab buttons to display only text provided

TabBar

NameTypeDefaultDescription
borderbooltrueToggles the border below the tab buttons
classNamestringnullString of classnames to add to the TabBar container
idstringuuid()String used as the id attribute of the TabBar container

TabItem

NameTypeDefaultDescription
activestringSets the pane's active state
addOnAppendstringIcon name to display before the label
addOnPrependstringIcon name to display after the label
classNamestringString of classnames to add to the TabPane container
iconOnlystringSets the tab buttons to display only icon provided
labelstringText value to display
onClickstringCallback function for when the tab is acted upon.
textOnlystringSets the tab buttons to display only text provided

TabPane

NameTypeDefaultDescription
activeboolfalseSets the pane's active state
classNamestringnullString of classnames to add to the TabPane container
idstringnullString used as the id attribute of the TabPane container
isAnimatedbooltrueDenotes if the panel ought to fade

Data Shape

NameTypeRequired?Description
classNamestringClassname for the TabPane
contentstringYesTabPane content
disabledboolSelecting TabItem is disabled
idstringId for the Tab
labelstring or {icon,text}Text label for the TabItem or an object containing the icon and/or text label for the TabItem
tabClassNamestringClassname for the TabItem
tabIdstringId value for the TabItem