Toolbars
ExpressiveDocked and floating toolbars of related actions, with an optional FAB, scroll collapse and scroll exit.
import { FloatingToolbar, DockedToolbar, ToolbarFab, useToolbarScrollExpansion, useToolbarScrollExit } from '@windmorph/react';Props
FloatingToolbar 17 props
The main controls, always shown.
Lay the controls out in a row, or in a column at a window edge.
The container colour:
standard(surface-container) orvibrant(primary-container).Level 1 elevation, which M3 gives floating toolbars by default. Remove it when the content beneath is visually distinct.
Shows the leading and trailing content, or (with a FAB) the toolbar itself. Collapse it while the page scrolls, e.g. with
useToolbarScrollExpansion. Collapsed controls stay in the tab order and the accessibility tree, and keyboard focus inside the toolbar expands it, so every control stays reachable.Shows the toolbar. Hiding it slides it off
exitEdge, e.g. while the page scrolls (useToolbarScrollExit). A hidden toolbar isinert. Don't combine it with collapsing: M3 says a toolbar shouldn't both collapse and leave the screen.The window edge a hidden toolbar slides past (logical).
Controls before the main content, hidden while collapsed.
Controls after the main content, hidden while collapsed.
A FAB beside the toolbar, usually a
ToolbarFab. Collapsing hides the toolbar and grows the FAB from 56px to 80px.Side of the toolbar the FAB sits on.
topis the same asstartandbottomasend, so the value can stay put when the orientation changes.Ref to the root element.
Text
Accessible name for the toolbar. Required unless
aria-labelledbyis set.The id of the element that names the toolbar. Required unless
aria-labelis set.
Classes for each part, by slot.
The outer container, merged with
className.The main content group.
The group of
leadingcontrols.The group of
trailingcontrols.The toolbar's surface when it has a FAB.
The box the FAB fills (56px, 80px while collapsed).
Inline styles for the root element.
Classes for the root element, merged with the component's own (yours win).
Also accepts the root element's HTML attributes (id, data-*, event handlers).
DockedToolbar 10 props
The toolbar's controls, e.g. icon buttons, buttons or a FAB.
Centre the items 32px apart (M3's default), or spread them across the toolbar, which M3 recommends in compact windows.
The container colour:
standard(surface-container) orvibrant(primary-container), as the floating toolbar's.Shows the toolbar. Hiding it slides it off the bottom of the window, e.g. while the page scrolls (
useToolbarScrollExit). A hidden toolbar isinert.Ref to the root element.
Text
Accessible name for the toolbar. Required unless
aria-labelledbyis set.The id of the element that names the toolbar. Required unless
aria-labelis set.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
ToolbarFab 22 props
The icon (while the toolbar is collapsed, when
expandedIconis set). Hidden from assistive tech;aria-labelnames the FAB.The icon while the toolbar is expanded, e.g. "close" for a FAB that collapses the toolbar. Without it, the FAB always shows
icon.How the FAB hands over between
iconandexpandedIcon:swaphalfway through the toolbar's expand / collapse spring, orrotate, where the outgoing icon turns 90° and fades out while the incoming one turns in and fades in.rotategoes beyond the M3 spec; it matches Google's Expressive showcase motion. It mirrors in RTL, and reduced motion keeps only the crossfade. Only used withexpandedIcon.The FAB's colour scheme. Defaults to the toolbar's colour:
primary-container(standard) ortertiary-container(vibrant).Shows
aria-labelin a plain tooltip on hover and keyboard focus, as M3 asks of FABs on the web.As on
Fab: level 2 by default (hover 3),loweredlevel 1, orflatlevel 0.Ref to the root element: the
<button>, or the<a>withhref.The value a submit button sends with its form, under its
name. On a toggle (toggle) it's astringnaming the button in a selection group instead, required to take part in the group's selection.The element is being dragged (e.g. a card picked up to move it): sets
data-draggedfor the dragged state layer. A consumer's owndata-draggedattribute counts too.Don't move focus to the element on press (set by menu triggers).
The element rendered: a native
<button>.Renders a link. Navigation goes through React Aria's
RouterProviderwhen one is set.
Text
Accessible name for the FAB, also its tooltip. Required unless
aria-labelledbyis set.The id of the element that names the FAB.
One of
aria-labeloraria-labelledbyis required.
Classes for each part, by slot.
Inline styles for the root element.
Classes for the root element, merged with
classNames.root; consumer classes win.
Handler that is called when the press is released over the target.
Handler that is called when a press interaction starts.
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
Handler that is called when the press state changes.
Handler that is called when a press is released over the target, regardless of whether it started on the target or not.
Also accepts every <a> or <button> attribute.
Tokens
M3's component tokens as CSS variables. Each is unset until you set it, on :root, a theme or any ancestor, and falls back to the default shown. The root carries data-variant (and data-size where it has sizes), which picks the variables that apply. See Component tokens in the Customisation guide.
| Variable | Default | Paints | Compose |
|---|---|---|---|
| Standard (color) | |||
--md-comp-toolbar-docked-container-color | var(--md-sys-color-surface-container) | The standard toolbar. | DockedToolbarTokens.ContainerColor |
| Vibrant (color) | |||
--md-comp-toolbar-vibrant-container-color | var(--md-sys-color-primary-container) | The vibrant toolbar. | |
| Variable | Default | Paints | Compose |
|---|---|---|---|
--md-comp-toolbar-floating-container-shape | var(--md-sys-shape-corner-full) | The corners. | FloatingToolbarTokens.ContainerShape |
| Standard (color) | |||
--md-comp-toolbar-floating-standard-container-color | var(--md-sys-color-surface-container) | The standard toolbar. | FloatingToolbarTokens.StandardContainerColor |
| Vibrant (color) | |||
--md-comp-toolbar-floating-vibrant-container-color | var(--md-sys-color-primary-container) | The vibrant toolbar. | FloatingToolbarTokens.VibrantContainerColor |
| Variable | Default | Paints |
|---|---|---|
--md-comp-toolbar-floating-fab-container-shape | var(--md-sys-shape-corner-large) | The corners. |
| Standard (color) | ||
--md-comp-toolbar-floating-fab-standard-container-color | var(--md-sys-color-primary-container) | The FAB beside a standard toolbar. |
--md-comp-toolbar-floating-fab-standard-icon-color | var(--md-sys-color-on-primary-container) | Its icon. |
| Vibrant (color) | ||
--md-comp-toolbar-floating-fab-vibrant-container-color | var(--md-sys-color-tertiary-container) | The FAB beside a vibrant toolbar. |
--md-comp-toolbar-floating-fab-vibrant-icon-color | var(--md-sys-color-on-tertiary-container) | Its icon. |
Hooks
useToolbarScrollExpansion
Collapses a floating toolbar while the content scrolls down and expands it when it scrolls back up, after a 40px threshold each way (a port of Compose's floatingToolbarVerticalNestedScroll). Pass the result to FloatingToolbar's expanded.
The scroll container. Defaults to the window.
Scroll distance (px) back towards the top before the toolbar expands.
Scroll distance (px) down before the toolbar collapses.
For content whose start is at the bottom (e.g. a conversation), which reverses the direction.
Whether the toolbar starts expanded, before the content has scrolled.
Returns boolean
useToolbarScrollExit
useToolbarScrollExit(options?: ToolbarScrollExitOptions): booleanSlides a docked or floating toolbar off the screen while the content scrolls down, and brings it back when it scrolls up, after a 40px threshold each way (M3's "animate offscreen" scroll behaviour, Compose's exitAlwaysScrollBehavior). Pass the result to the toolbar's visible. Use it instead of useToolbarScrollExpansion, not with it.
The scroll container. Defaults to the window.
Scroll distance (px) back towards the top before the toolbar returns.
Scroll distance (px) down before the toolbar leaves the screen.
For content whose start is at the bottom (e.g. a conversation), which reverses the direction.
Whether the toolbar starts on screen, before the content has scrolled.
Returns boolean
Spec status
Built to the M3 Expressive toolbars spec. Each item of its variants and configurations links to a live example; where the M3 Expressive column of the spec differs from the original M3 one, it wins.
| Item | Status | Details |
|---|---|---|
| Docked toolbar | Built | Variant · Docked |
| Floating toolbar | Built | Variant · Floating, Vertical |
| Color: standard | Built | Configuration · Floating, Vertical |
| Color: vibrant | Built | Configuration · Floating, Overflow, Docked |
| Floating toolbar layout: horizontal | Built | Configuration · Floating |
| Floating toolbar layout: vertical | Built | Configuration · Vertical |
| With FAB | Built | Configuration · Fab scroll, Vertical |
| Overflow menu in the trailing slot | Built | Use case · Overflow, Docked overflow |
| Collapsing or leaving the screen on scroll | Built | Use case · Fab scroll, Scroll exit |
| Leaving the screen | Differs | useToolbarScrollExit slides the toolbar away after 40px of scrolling, without following the finger. |
ToolbarFab iconTransition="rotate" | Extension | Not in the M3 spec: with expandedIcon, the FAB's icon turns 90° and fades into the other as the toolbar expands (counter-clockwise, mirrored in RTL) or collapses, instead of swapping halfway, as in Google's Expressive showcase. Reduced motion keeps only the crossfade. |
ToolbarFab elevation | Extension | As on Fab: lowered (level 1) or flat (level 0) for a FAB beside a flat toolbar. |
| Bottom app bar (baseline) | Not built | Deprecated in M3 Expressive; the docked toolbar replaces it. |
| Scroll collapse for the docked toolbar | Not built | Deferred; a docked toolbar can leave the screen on scroll with useToolbarScrollExit. |
Docked toolbar
BuiltVariant · Docked
Floating toolbar layout: horizontal
BuiltConfiguration · Floating
Floating toolbar layout: vertical
BuiltConfiguration · Vertical
With FAB
BuiltConfiguration · Fab scroll, Vertical
Overflow menu in the trailing slot
BuiltUse case · Overflow, Docked overflow
Collapsing or leaving the screen on scroll
BuiltUse case · Fab scroll, Scroll exit
Leaving the screen
DiffersuseToolbarScrollExitslides the toolbar away after 40px of scrolling, without following the finger.
ExtensionToolbarFabiconTransition="rotate"Not in the M3 spec: with
expandedIcon, the FAB's icon turns 90° and fades into the other as the toolbar expands (counter-clockwise, mirrored in RTL) or collapses, instead of swapping halfway, as in Google's Expressive showcase. Reduced motion keeps only the crossfade.
ExtensionToolbarFabelevationAs on
Fab:lowered(level 1) orflat(level 0) for a FAB beside a flat toolbar.Bottom app bar (baseline)
Not builtDeprecated in M3 Expressive; the docked toolbar replaces it.
Scroll collapse for the docked toolbar
Not builtDeferred; a docked toolbar can leave the screen on scroll with
useToolbarScrollExit.
Bundle size
Gzipped, as published: the component and the library code it imports. React, React Aria, Motion and the other dependencies aren't counted, and your bundler's minifier makes it smaller still. CI fails a change that grows it past its budget.
FloatingToolbar,DockedToolbar,ToolbarFab: 24.0 kB
M3 Expressive specs
- Variants
docked, floating
Spec values and differences
- Compose forces the toolbar open under a screen reader and adds expand / collapse actions. The web cannot detect either, so collapsed controls stay reachable and focus on them expands the toolbar.
- Leading / trailing content opens to its measured width on the fast spatial spring, overshooting as Compose's
expandHorizontallydoes, and closes on the fast effects curve (a size can't go below 0), clipping only along the toolbar so focus rings and touch targets survive. With a FAB, the toolbar keeps its measured width while the surface springs to 0 and the FAB's box grows 56 → 80px. useToolbarScrollExpansionports Compose's vertical nested-scroll behaviour: 40px down collapses, 40px back up expands. There is noonExpandedChange, since nothing inside changes it.useToolbarScrollExitfollows Compose's exit-always behaviour with the same 40px thresholds: the toolbar slides past its edge on the fast spatial spring (atransformset only while hidden, so it composes with Tailwind'stranslate-*utilities). It doesn't follow the finger.- There is no built-in overflow row: compose a
MenuTriggerin the trailing slot, as in the example.