Skip to content

Toolbars

Expressive

Docked 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

By name or description, across the 49 props below

FloatingToolbar 17 props

  • childrentype ReactNodeRequired

    The main controls, always shown.

  • orientationtype "horizontal" | "vertical"default "horizontal"

    Lay the controls out in a row, or in a column at a window edge.

  • colortype "standard" | "vibrant"default "standard"

    The container colour: standard (surface-container) or vibrant (primary-container).

  • elevatedtype booleandefault true

    Level 1 elevation, which M3 gives floating toolbars by default. Remove it when the content beneath is visually distinct.

  • expandedtype booleandefault true

    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.

  • visibletype booleandefault true

    Shows the toolbar. Hiding it slides it off exitEdge, e.g. while the page scrolls (useToolbarScrollExit). A hidden toolbar is inert. Don't combine it with collapsing: M3 says a toolbar shouldn't both collapse and leave the screen.

  • exitEdgetype "start" | "end" | "top" | "bottom"default "bottom"

    The window edge a hidden toolbar slides past (logical).

  • leadingtype ReactNode

    Controls before the main content, hidden while collapsed.

  • trailingtype ReactNode

    Controls after the main content, hidden while collapsed.

  • fabtype ReactElement<unknown, string | JSXElementConstructor<any>>

    A FAB beside the toolbar, usually a ToolbarFab. Collapsing hides the toolbar and grows the FAB from 56px to 80px.

  • fabPlacementtype "start" | "end" | "top" | "bottom"default "end"

    Side of the toolbar the FAB sits on. top is the same as start and bottom as end, so the value can stay put when the orientation changes.

  • reftype Ref<HTMLDivElement>

    Ref to the root element.

Text

  • aria-labeltype string

    Accessible name for the toolbar. Required unless aria-labelledby is set.

  • aria-labelledbytype string

    The id of the element that names the toolbar. Required unless aria-label is set.

Also accepts the root element's HTML attributes (id, data-*, event handlers).

DockedToolbar 10 props

  • childrentype ReactNodeRequired

    The toolbar's controls, e.g. icon buttons, buttons or a FAB.

  • arrangementtype "space-between" | "centered"default "centered"

    Centre the items 32px apart (M3's default), or spread them across the toolbar, which M3 recommends in compact windows.

  • colortype "standard" | "vibrant"default "standard"

    The container colour: standard (surface-container) or vibrant (primary-container), as the floating toolbar's.

  • visibletype booleandefault true

    Shows the toolbar. Hiding it slides it off the bottom of the window, e.g. while the page scrolls (useToolbarScrollExit). A hidden toolbar is inert.

  • reftype Ref<HTMLDivElement>

    Ref to the root element.

Text

  • aria-labeltype string

    Accessible name for the toolbar. Required unless aria-labelledby is set.

  • aria-labelledbytype string

    The id of the element that names the toolbar. Required unless aria-label is set.

Also accepts the root element's HTML attributes (id, data-*, event handlers).

ToolbarFab 22 props

  • icontype ReactElement<unknown, string | JSXElementConstructor<any>>Required

    The icon (while the toolbar is collapsed, when expandedIcon is set). Hidden from assistive tech; aria-label names the FAB.

  • expandedIcontype ReactElement<unknown, string | JSXElementConstructor<any>>

    The icon while the toolbar is expanded, e.g. "close" for a FAB that collapses the toolbar. Without it, the FAB always shows icon.

  • iconTransitiontype "swap" | "rotate"default "swap"

    How the FAB hands over between icon and expandedIcon: swap halfway through the toolbar's expand / collapse spring, or rotate, where the outgoing icon turns 90° and fades out while the incoming one turns in and fades in. rotate goes beyond the M3 spec; it matches Google's Expressive showcase motion. It mirrors in RTL, and reduced motion keeps only the crossfade. Only used with expandedIcon.

  • colortype "standard" | "vibrant"default the toolbar's color, or "standard" outside a toolbar

    The FAB's colour scheme. Defaults to the toolbar's colour: primary-container (standard) or tertiary-container (vibrant).

  • tooltiptype booleandefault true

    Shows aria-label in a plain tooltip on hover and keyboard focus, as M3 asks of FABs on the web.

  • elevationtype "flat" | "default" | "lowered"default "default"

    As on Fab: level 2 by default (hover 3), lowered level 1, or flat level 0.

  • reftype Ref<HTMLButtonElement> | Ref<HTMLAnchorElement>

    Ref to the root element: the <button>, or the <a> with href.

  • valuetype string | number | readonly string[]

    The value a submit button sends with its form, under its name. On a toggle (toggle) it's a string naming the button in a selection group instead, required to take part in the group's selection.

  • draggedtype booleandefault false

    The element is being dragged (e.g. a card picked up to move it): sets data-dragged for the dragged state layer. A consumer's own data-dragged attribute counts too.

  • preventFocusOnPresstype booleandefault false

    Don't move focus to the element on press (set by menu triggers).

  • astype "button"default "button"

    The element rendered: a native <button>.

  • hreftype string

    Renders a link. Navigation goes through React Aria's RouterProvider when one is set.

Text

  • aria-labeltype string

    Accessible name for the FAB, also its tooltip. Required unless aria-labelledby is set.

  • aria-labelledbytype string

    The id of the element that names the FAB.

    One of aria-label or aria-labelledby is required.

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.

Toolbars tokens (md-comp-toolbar-docked)
VariableDefaultPaintsCompose
Standard (color)
--md-comp-toolbar-docked-container-colorvar(--md-sys-color-surface-container)The standard toolbar.DockedToolbarTokens.ContainerColor
Vibrant (color)
--md-comp-toolbar-vibrant-container-colorvar(--md-sys-color-primary-container)The vibrant toolbar.
Toolbars tokens (md-comp-toolbar-floating)
VariableDefaultPaintsCompose
--md-comp-toolbar-floating-container-shapevar(--md-sys-shape-corner-full)The corners.FloatingToolbarTokens.ContainerShape
Standard (color)
--md-comp-toolbar-floating-standard-container-colorvar(--md-sys-color-surface-container)The standard toolbar.FloatingToolbarTokens.StandardContainerColor
Vibrant (color)
--md-comp-toolbar-floating-vibrant-container-colorvar(--md-sys-color-primary-container)The vibrant toolbar.FloatingToolbarTokens.VibrantContainerColor
Toolbars tokens (md-comp-toolbar-floating-fab)
VariableDefaultPaints
--md-comp-toolbar-floating-fab-container-shapevar(--md-sys-shape-corner-large)The corners.
Standard (color)
--md-comp-toolbar-floating-fab-standard-container-colorvar(--md-sys-color-primary-container)The FAB beside a standard toolbar.
--md-comp-toolbar-floating-fab-standard-icon-colorvar(--md-sys-color-on-primary-container)Its icon.
Vibrant (color)
--md-comp-toolbar-floating-fab-vibrant-container-colorvar(--md-sys-color-tertiary-container)The FAB beside a vibrant toolbar.
--md-comp-toolbar-floating-fab-vibrant-icon-colorvar(--md-sys-color-on-tertiary-container)Its icon.

Hooks

useToolbarScrollExpansion

useToolbarScrollExpansion signature
useToolbarScrollExpansion(options?: ToolbarScrollExpansionOptions): boolean

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.

  • optionstype ToolbarScrollExpansionOptions
  • options.scrollReftype React.RefObject<HTMLElement | null>

    The scroll container. Defaults to the window.

  • options.expandThresholdtype numberdefault 40

    Scroll distance (px) back towards the top before the toolbar expands.

  • options.collapseThresholdtype numberdefault 40

    Scroll distance (px) down before the toolbar collapses.

  • options.reversetype booleandefault false

    For content whose start is at the bottom (e.g. a conversation), which reverses the direction.

  • options.defaultExpandedtype booleandefault true

    Whether the toolbar starts expanded, before the content has scrolled.

Returns boolean

useToolbarScrollExit

useToolbarScrollExit signature
useToolbarScrollExit(options?: ToolbarScrollExitOptions): boolean

Slides 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.

  • optionstype ToolbarScrollExitOptions
  • options.scrollReftype React.RefObject<HTMLElement | null>

    The scroll container. Defaults to the window.

  • options.showThresholdtype numberdefault 40

    Scroll distance (px) back towards the top before the toolbar returns.

  • options.hideThresholdtype numberdefault 40

    Scroll distance (px) down before the toolbar leaves the screen.

  • options.reversetype booleandefault false

    For content whose start is at the bottom (e.g. a conversation), which reverses the direction.

  • options.defaultVisibletype booleandefault true

    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.

  • 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.

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 expandHorizontally does, 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.
  • useToolbarScrollExpansion ports Compose's vertical nested-scroll behaviour: 40px down collapses, 40px back up expands. There is no onExpandedChange, since nothing inside changes it.
  • useToolbarScrollExit follows Compose's exit-always behaviour with the same 40px thresholds: the toolbar slides past its edge on the fast spatial spring (a transform set only while hidden, so it composes with Tailwind's translate-* utilities). It doesn't follow the finger.
  • There is no built-in overflow row: compose a MenuTrigger in the trailing slot, as in the example.