Skip to content

FAB menu

Expressive

A FAB that opens two to six related actions above it, or a menu on the web.

import { FabMenu, FabMenuItem } from '@windmorph/react';

Props

By name or description, across the 37 props below

FabMenu 20 props

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

    The button's icon while closed, usually "add". Hidden from assistive tech.

  • childrentype ReactNodeRequired

    Two to six FabMenuItem elements, top to bottom.

  • opentype boolean

    Whether the menu is open (controlled).

  • defaultOpentype booleandefault false

    Whether the menu starts open (uncontrolled).

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

    The button's icon while open, usually "close". Defaults to icon.

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

    How the button hands over from icon to openIcon: swap halfway through the morph (the M3 spec and Compose), 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 openIcon.

  • sizetype "default" | "md" | "lg"default "default"

    The FAB size the button starts at; open, it is always the 56px close button.

  • colortype "primary" | "secondary" | "tertiary"default "primary"

    The button's and items' colour scheme, from M3's FAB menu colour sets.

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

    The button's and items' elevation, as on Fab: level 3 by default (the spec), lowered level 1, or flat level 0.

  • presentationtype "menu" | "list"default "list"

    How the items show: list, the expressive stack of pills above the button, or menu, a standard menu 4px above it (M3's choice for the web and large windows).

  • tooltiptype booleandefault true

    While closed, shows aria-label in a plain tooltip on hover and keyboard focus, as M3 asks of FABs on the web. Open, the button is the close button and has no tooltip. It steps aside inside your own TooltipTrigger.

  • visibletype booleandefault true

    Shows the button. Hiding it closes the menu, shrinks the button towards its centre and fades it out; showing it expands it back (the FAB's appear / disappear motion). A hidden menu is inert.

  • appeartype booleandefault false

    Plays the appearing animation when the menu mounts. Change its key on a page or tab change to replay it.

  • reftype Ref<HTMLDivElement>

    Ref to the root element.

Events

  • onOpenChangetype ((open: boolean) => void)

    Called when the menu opens or closes.

Text

  • aria-labeltype string

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

  • aria-labelledbytype string

    The id of the element that names the button.

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

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

FabMenuItem 17 props

  • childrentype ReactNodeRequired

    The label, which M3 always requires.

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

    The item's icon. Hidden from assistive tech; the label names the item. M3 asks for an icon on every item, since it tells the items apart; leave it out only if necessary.

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

Events

  • onActiontype (() => void)

    Runs when the item is chosen, in either presentation. (onPress works only in the list, since a menu item has no press event.)

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.

FAB menu tokens (md-comp-fab-menu)
VariableDefaultPaintsCompose
--md-comp-fab-menu-close-button-container-shape28pxThe open close button’s corners (half its 56px size, so they animate).FabMenuBaselineTokens.CloseButtonContainerShape
--md-comp-fab-menu-menu-item-container-shapevar(--md-sys-shape-corner-full)The corners of the list’s items.FabMenuBaselineTokens.ListItemContainerShape
Primary (color)
--md-comp-fab-menu-primary-close-button-container-colorvar(--md-sys-color-primary)The open close button.
--md-comp-fab-menu-primary-close-button-icon-colorvar(--md-sys-color-on-primary)The open close button’s icon.
Secondary (color)
--md-comp-fab-menu-secondary-close-button-container-colorvar(--md-sys-color-secondary)The open close button.
--md-comp-fab-menu-secondary-close-button-icon-colorvar(--md-sys-color-on-secondary)The open close button’s icon.
Tertiary (color)
--md-comp-fab-menu-tertiary-close-button-container-colorvar(--md-sys-color-tertiary)The open close button.
--md-comp-fab-menu-tertiary-close-button-icon-colorvar(--md-sys-color-on-tertiary)The open close button’s icon.
Primary-container (item-color)
--md-comp-fab-menu-primary-container-list-item-container-colorvar(--md-sys-color-primary-container)The list’s items.
--md-comp-fab-menu-primary-container-list-item-label-text-colorvar(--md-sys-color-on-primary-container)The items’ labels.
--md-comp-fab-menu-primary-container-list-item-icon-colorvar(--md-sys-color-on-primary-container)The items’ icons.
Secondary-container (item-color)
--md-comp-fab-menu-secondary-container-list-item-container-colorvar(--md-sys-color-secondary-container)The list’s items.
--md-comp-fab-menu-secondary-container-list-item-label-text-colorvar(--md-sys-color-on-secondary-container)The items’ labels.
--md-comp-fab-menu-secondary-container-list-item-icon-colorvar(--md-sys-color-on-secondary-container)The items’ icons.
Tertiary-container (item-color)
--md-comp-fab-menu-tertiary-container-list-item-container-colorvar(--md-sys-color-tertiary-container)The list’s items.
--md-comp-fab-menu-tertiary-container-list-item-label-text-colorvar(--md-sys-color-on-tertiary-container)The items’ labels.
--md-comp-fab-menu-tertiary-container-list-item-icon-colorvar(--md-sys-color-on-tertiary-container)The items’ icons.

Spec status

Built to the M3 Expressive fab menu 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.

  • FAB menu

    Built

    Variant · Basic

  • Color: primary, secondary, tertiary set

    Built

    Configuration · Colors

  • Opening from a medium or large FAB

    Built

    Configuration · Web

  • A menu on the web

    Built

    Use case · Web

  • Outside press closes it

    Extension

    Compose relies on the system back button, which the web doesn't have, so an outside press closes the menu too.

  • Appear and disappear

    Extension

    visible and appear give the menu's FAB the FAB's own disappear and reappear motion.

  • iconTransition="rotate"

    Extension

    Not in the M3 spec, which swaps icon for openIcon halfway through the morph: the outgoing icon turns 90° counter-clockwise on open (mirrored in RTL) and fades out as the incoming one turns in. Matches Google's Expressive showcase motion; reduced motion keeps only the crossfade.

  • elevation

    Extension

    As on Fab: lowered (level 1) or flat (level 0, the spec's level for a FAB nested in another surface) for the button and its items.

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.

  • FabMenu, FabMenuItem: 48.4 kB

M3 Expressive specs

Shape
rounded-corner-large
Elevation
level3

Spec values and differences

  • No shape morph: Compose's FAB menu does not use the shape library.
  • The toggle button keeps its FAB's layout box (56 / 80 / 96px) in a library-owned anchor; open, it becomes the 56px close button with 28px corners and a 20px icon. Size, corners and icon follow the fast spatial spring; the colours move from the *-container role to the vibrant role on the fast effects spring, so they never overshoot.
  • Items are 56px pills (min 56px wide, 24px padding, 8px icon gap, 24px icon, title-medium), 4px apart and 8px above the button.
  • The button and the items sit at level 3, as the spec asks; elevation works as on Fab, with lowered (level 1) and flat (level 0).
  • iconTransition="rotate" goes beyond the spec, which swaps the icons halfway through the morph: the icons turn 90° counter-clockwise as the menu opens (mirrored in RTL) while they crossfade, and turn back as it closes. Reduced motion keeps only the crossfade.
  • Opening staggers the visible item count on the slow effects spring (the item nearest the button appears first); each item then springs its width on fast spatial and its opacity on fast effects. Closing hides the top item first.
  • Colour sets are primary | secondary | tertiary (m3.material.io's sets; Compose's default is primary).
  • A development warning flags a menu with fewer than two or more than six items.