Floating nav
Floating nav is a pill of destinations that floats above the bottom of a phone screen. The current item stretches to show its name, and the bar can step out of the way while people read. It's the nav on this site when you open it on a phone.
Examples
Liquid glass
variant="glass" draws the bar as liquid glass. A lightly frosted, tinted
layer and a bright rim work in every browser. In Chromium the page behind the
rim also bends, through an SVG displacement filter sized to the bar; Safari and
Firefox keep the blur and rim. The current item sits under a glass lens that
overshoots a little as it lands, and the bar swells a touch under a finger.
Pressing the bar lifts the lens off it, the way iOS does as you change tabs: it grows past the bar's edges, clears, and magnifies the item beneath with a fringe of colour at its rim, then travels to the new item and settles back into its tint. In Safari and Firefox it lifts and clears without the magnifying. With reduced motion it stays put.
The glass bar doesn't clip, so the lens can lift past it, which also means it
can't scroll sideways the way the default bar does when its items outgrow the
screen. Keep a glass bar to items that fit, or switch to size="sm" on narrow
screens.
The golden section turns up in seed heads, shells and the spiral of a rabbit population, each term the sum of the two before.
Labels and size
Text items
Leave out an item's icon and it shows its label as text, always. Use it when
there are only two or three places and their names say more than icons.
Static
position="static" keeps the bar in the flow, for a toolbar at the foot of a
card or a preview like this one.
With your router
Items with an href render as links. onValueChange hands over the click, so
an app can call event.preventDefault() and route it itself.
Anatomy
A nav landmark holding a pill. Each item is a link or a button, with an icon, a label and, on the current one, the fill behind it. A text item has no icon.
Guidelines
- 01Use it for the three to five places people move between most on a phone. Everything else belongs in a menu.
- 02Keep labels to one short word. The current label has to fit beside its icon on a 320px screen.
- 03Turn on
hideOnScrollfor reading surfaces such as articles and docs. Leave it off where people switch places often. - 04Pad the bottom of the page by the bar's height, about
6rem, so the last content can scroll clear of it. - 05Hide it at desktop widths, where a sidebar or top bar already does the job.
Best practices
Accessibility
Every item is a plain link or button in tab order, so the bar works from the keyboard without anything to learn.
| Key | Does |
|---|---|
| Tab | DoesMoves between the items |
| ↵ | DoesGoes to the item's destination |
| Space | DoesGoes to the destination of a button item |
- 01The root is a
navlandmark, named Main unless you passaria-label. Name it when a page has more than one. - 02The current item carries
aria-current="page"when it's a link, oraria-current="true"when it's a button. Hidden labels stay in the DOM, so every item keeps its name. - 03A hidden bar takes no taps or clicks, so it can't catch one meant for the page beneath. Its items stay in the tab order, and tabbing into it brings it back.
- 04Glass shows the page through it, so its labels' contrast depends on what scrolls beneath. Use it over images and media, and the default bar over dense text.
- 05Every item is at least 44px square, or 36px with size="sm", well above the 24px minimum target.
- 06With reduced motion, the indicator and the bar move without animating.
Related components
- Command menuA Cmd+K palette with nested pages, recent commands, ranked search and a preview pane.
- Chapter scrubberA rail of marks that swell under the pointer like the Dock, previewing the chapter at the crest.
References
- WAI-ARIA
aria-current, for marking the current page - Apple's Human Interface Guidelines on tab bars, for counts and label length
- Motion, for the layout animation