FAB menu
ExpressiveA FAB that opens two to six related actions above it, or a menu on the web.
import { FabMenu, FabMenuItem } from '@windmorph/react';Keyboard
| Key | Action | Where |
|---|---|---|
| Enter or Space | Opens or closes the menu from the button; focus stays on the button. On an item, runs it and closes the menu. | |
| Tab | Moves from the button to the top item, down through the items, then out of the menu. Focus leaving the open menu, with Tab or Shift+Tab from any of its parts, closes it, as an outside press does. | |
| Arrow Down | Moves focus from the button to the top item, then down through the items; from the bottom item it returns to the button.While open | While open |
| Arrow Up | Moves focus up through the items; from the top item it returns to the button.While open | While open |
| Escape | Closes the menu and puts focus on the button.While open | While open |
| Enter or Space or Arrow Down or Arrow Up or Escape | With presentation="menu" the keys are those of any Menu: the button opens it with focus on the first item (Arrow Up: the last), the arrows move between items, typing jumps to an item, and Escape closes it.Menu presentation | Menu presentation |
Screen reader
- Role
- The toggle is a
button; in the list each item is abutton(alinkwithhref). Withpresentation="menu"the button opens amenuofmenuitems. - Accessible name
- The button takes
aria-labeloraria-labelledby, one of which is required; each item is named by its label. The menu presentation names themenuwith the same label. - States announced
- In the list, the button reports
aria-expandedandaria-controls(the list). Withpresentation="menu"it reportsaria-haspopupandaria-expanded.
- The button and item icons are hidden from assistive tech (
aria-hidden). - While closed, the button shows its
aria-labelin a plain tooltip on hover, keyboard focus and a touch long press; the tooltip repeats the button's name, so it isn't linked as its description. Open, it is the close button and has none. It steps aside inside your ownTooltipTrigger, andtooltip={false}turns it off. - Hidden items are
inert, so they are out of the Tab order and the accessibility tree while the menu is closed. A hidden menu (visible={false}) isinertas a whole.
Focus
- Opening keeps focus on the button, which becomes the close button. The DOM order is the button, then the items from the top down, even though the items show above the button.
- Choosing an item, or Escape, closes the menu and puts focus back on the button. An outside press closes it without moving focus.
- Keyboard focus shows M3's focus indicator on the button and on each item: a 3px
secondaryoutline 2px outside it. The list keeps 16px of room around its items, so their rings aren't clipped when it scrolls.
Touch target
The button is 56, 80 or 96px square, and 56px open; each item is a 56px-tall pill at least 56px wide. All meet the 48px minimum without an extra touch target.
Motion
- Under reduced motion, hiding and showing the menu (
visible,appear) only fade, without the scale from the centre; theswapicon change happens at once, androtatekeeps only the crossfade. The press ripple appears at full size without growing. - Opening and closing don't move either: the button becomes the close button at once, and the items fade in and out together, at their full width, without the stagger.
What you need to do
- Name the button with an
aria-labelthat says what the menu holds ("Create"), and give every item a visible label. - Give the menu two to six related actions. For a single action use a
Fab. - Use
presentation="menu"in large windows and on the web, where M3 asks for a standard menu.