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';Keyboard
| Key | Action | Where |
|---|---|---|
| Tab or Shift + Tab | Moves through every control in order, then out of the toolbar. Tab enters at the first control and Shift + Tab at the last. | |
| Arrow Left or Arrow Right | Moves focus to the previous or next control, wrapping from the last to the first and back.Horizontal toolbar | Horizontal toolbar |
| Arrow Up or Arrow Down | Moves focus to the previous or next control, wrapping from the last to the first and back.Vertical floating toolbar | Vertical floating toolbar |
| Home or End | Moves focus to the first or the last control. | |
| Enter or Space | Activates the focused control. |
- Tab follows the M3 spec ("Tab or Arrows: Navigate between interactive elements") rather than the WAI-ARIA toolbar pattern, where the whole toolbar is a single Tab stop. The arrow keys, Home and End follow the WAI-ARIA toolbar.
- A text field in a toolbar keeps the arrow keys, Home and End for its caret.
- The horizontal arrow keys follow the DOM direction, so they are mirrored right to left.
Screen reader
- Role
toolbar(groupwhen nested in another toolbar), from React Aria. The controls inside keep their own roles.- Accessible name
- The toolbar is named by
aria-labeloraria-labelledby, which the types require.ToolbarFabis named by its ownaria-labeloraria-labelledby, which its types require too. - States announced
- None of its own. The controls announce their own states, such as pressed for a toggle icon button.
- Collapsed leading and trailing controls (
expanded={false}) stay in the accessibility tree, clipped to nothing, so a screen reader still reaches them. - A toolbar that has left the screen (
visible={false}) isinert, so it is out of the Tab order and the accessibility tree. ToolbarFab's icon is hidden from assistive tech (aria-hidden).
Focus
- Each control shows its own focus ring on keyboard focus.
- Collapsed controls stay in the Tab order. Focus reaching them, from the keyboard or a screen reader, expands the toolbar, and keyboard focus anywhere inside keeps it expanded; pointer focus on the always-shown controls doesn't.
ToolbarFabshows itsaria-labelin a plain tooltip on hover and keyboard focus (tooltip, on by default).
Touch target
- The toolbars add no targets of their own. Their icon buttons are
standardIconButtons, which keep their own 48 × 48px touch target. ToolbarFabis 56 × 56px, and 80 × 80px while the toolbar is collapsed.
Motion
- Under reduced motion a toolbar leaving the screen fades out instead of sliding off its edge.
- Collapsing and expanding happen at once, without the width animating.
ToolbarFab'srotateicon transition keeps only the crossfade.
What you need to do
- Name every toolbar with
aria-labeloraria-labelledby("Message actions"). - Give every icon-only control an
aria-label, andToolbarFabanaria-labelthat says what it does. - Don't both collapse a floating toolbar and hide it (
expandedandvisible); M3 says a toolbar shouldn't do both, and the component warns in development.