TabBarItem
One tab of a TabBar: a link with an icon over a label, and an optional badge count, current while the route is inside it.
Stability: experimental
Props
| Prop | Type | Default | Means |
|---|---|---|---|
label | string | The tab's name, shown under the icon. | |
icon | string | An icon from the built-in set. | |
href | string | The route the tab opens. Pressing it switches screens with a crossfade, and starts a part of the app: the screen it opens has no back button. Matched without its query, fragment or trailing slash, decoded. | |
badge | number | A count on the icon, such as unread messages; none when 0 or left out, 99+ above 99. | |
exact | boolean | false | Current only at href itself, not at the routes below it. href="/" is always matched exactly. |
current | boolean | Overrides the matching, for a tab that owns routes outside its href, such as a feed whose posts open at /post/7. |
States
| State | Looks like |
|---|---|
current | Icon and label in the primary colour; muted otherwise. |
pressed | The icon scales to 92%. |
focused | A 2px primary outline inside the tab. |
badge | A danger-coloured pill at the icon's top trailing corner, ringed with the bar's surface. |
Accessibility
| role | link |
| name | The label, then ", 3 new" while the badge is above 0. |
| focus | Tab reaches it; it is an ordinary link. |
| keyboard | Enter follows it. |
| notes | While current it has aria-current="page"; otherwise no aria-current at all. Matching follows the route as it changes: by default, current at href and at any path below it (/inbox matches /inbox/7, not /inboxes). |
Theme tokens
color.muted color.primary color.danger color.on-primary color.surface space.1 radius.md radius.full text.caption
Example
<TabBarItem label="Inbox" icon="inbox" href="/inbox" badge={unread.length} />