Skip to content

FAB

Expressive

A screen's single most important action, as an icon or an extended label.

import { Fab, ExtendedFab } from '@windmorph/react';

Props

By name or description, across the 48 props below

Fab 23 props

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

    The icon. Hidden from assistive tech; aria-label names the FAB.

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

    Container size: default (56px), md (medium, 80px) or lg (large, 96px). The small FAB is deprecated in M3 Expressive.

  • tooltiptype booleandefault true

    Shows aria-label in a plain tooltip on hover and keyboard focus, as M3 asks of FABs on the web. Turn it off when you wrap the FAB in your own TooltipTrigger.

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

    The colour style: a container colour or its solid form.

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

    default is level 3 (hover 4); lowered is level 1 (hover 2), for FABs on surfaces that already sit above the page; flat is level 0, for a FAB nested in another component such as the navigation rail.

  • visibletype booleandefault true

    Shows the FAB. Hiding it shrinks it towards its centre and fades it out; showing it expands it back, so it can disappear and reappear around a page or tab change. A hidden FAB is inert.

  • appeartype booleandefault false

    Plays the appearing animation when the FAB mounts. Change the FAB's key on a page or tab change to replay it.

  • 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

    The FAB's accessible name, also shown in its tooltip. Required without aria-labelledby.

  • aria-labelledbytype string

    The id of an element that names the FAB, instead of aria-label.

Also accepts every <a> or <button> attribute.

ExtendedFab 25 props

  • childrentype string | number | bigint | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...>Required

    The visible label; it also names the FAB, including while collapsed.

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

    Container height and label size: small (56px), medium (80px) or large (96px).

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

    Leading icon. Needed for the collapsed state, which shows the icon only.

  • expandedtype booleandefault true

    Shows the label. Collapsing animates the FAB to a square showing only the icon (e.g. while the page scrolls).

  • tooltiptype booleandefault true

    While collapsed, shows the label (or aria-label) in a plain tooltip on hover and keyboard focus, as M3 asks of icon-only FABs on the web. Expanded, the label is visible and there is no tooltip. It steps aside inside your own TooltipTrigger.

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

    The colour style: a container colour or its solid form.

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

    default is level 3 (hover 4); lowered is level 1 (hover 2), for FABs on surfaces that already sit above the page; flat is level 0, for a FAB nested in another component such as the navigation rail.

  • visibletype booleandefault true

    Shows the FAB. Hiding it shrinks it towards its centre and fades it out; showing it expands it back, so it can disappear and reappear around a page or tab change. A hidden FAB is inert.

  • appeartype booleandefault false

    Plays the appearing animation when the FAB mounts. Change the FAB's key on a page or tab change to replay it.

  • 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

    A name that replaces the label, only to add detail. Start it with the visible label's first word ("Create a new invite" for "Create"), as M3 asks, so voice control can name the FAB; it warns once in development when the first words differ.

  • aria-labelledbytype string

    The id of an element that names the FAB instead of its label.

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 tokens (md-comp-fab)
VariableDefaultPaintsCompose
Primary-container (color)
--md-comp-fab-primary-container-container-colorvar(--md-sys-color-primary-container)The container.FabPrimaryContainerTokens.ContainerColor
--md-comp-fab-primary-container-icon-colorvar(--md-sys-color-on-primary-container)The icon.FabPrimaryContainerTokens.IconColor
Secondary-container (color)
--md-comp-fab-secondary-container-container-colorvar(--md-sys-color-secondary-container)The container.FabSecondaryContainerTokens.ContainerColor
--md-comp-fab-secondary-container-icon-colorvar(--md-sys-color-on-secondary-container)The icon.FabSecondaryContainerTokens.IconColor
Tertiary-container (color)
--md-comp-fab-tertiary-container-container-colorvar(--md-sys-color-tertiary-container)The container.
--md-comp-fab-tertiary-container-icon-colorvar(--md-sys-color-on-tertiary-container)The icon.
Primary (color)
--md-comp-fab-primary-container-colorvar(--md-sys-color-primary)The container.
--md-comp-fab-primary-icon-colorvar(--md-sys-color-on-primary)The icon.
Secondary (color)
--md-comp-fab-secondary-container-colorvar(--md-sys-color-secondary)The container.
--md-comp-fab-secondary-icon-colorvar(--md-sys-color-on-secondary)The icon.
Tertiary (color)
--md-comp-fab-tertiary-container-colorvar(--md-sys-color-tertiary)The container.
--md-comp-fab-tertiary-icon-colorvar(--md-sys-color-on-tertiary)The icon.
Default (size)
--md-comp-fab-container-shapevar(--md-sys-shape-corner-large)The corners.FabBaselineTokens.ContainerShape
Md (size)
--md-comp-fab-medium-container-shapevar(--md-sys-shape-corner-large-increased)The corners.FabMediumTokens.ContainerShape
Lg (size)
--md-comp-fab-large-container-shapevar(--md-sys-shape-corner-extra-large)The corners.FabLargeTokens.ContainerShape
FAB tokens (md-comp-extended-fab)
VariableDefaultPaintsCompose
Primary-container (color)
--md-comp-extended-fab-primary-container-container-colorvar(--md-sys-color-primary-container)The container.
--md-comp-extended-fab-primary-container-label-text-colorvar(--md-sys-color-on-primary-container)The label and the icon, which follows it.
Secondary-container (color)
--md-comp-extended-fab-secondary-container-container-colorvar(--md-sys-color-secondary-container)The container.
--md-comp-extended-fab-secondary-container-label-text-colorvar(--md-sys-color-on-secondary-container)The label and the icon, which follows it.
Tertiary-container (color)
--md-comp-extended-fab-tertiary-container-container-colorvar(--md-sys-color-tertiary-container)The container.
--md-comp-extended-fab-tertiary-container-label-text-colorvar(--md-sys-color-on-tertiary-container)The label and the icon, which follows it.
Primary (color)
--md-comp-extended-fab-primary-container-colorvar(--md-sys-color-primary)The container.
--md-comp-extended-fab-primary-label-text-colorvar(--md-sys-color-on-primary)The label and the icon, which follows it.
Secondary (color)
--md-comp-extended-fab-secondary-container-colorvar(--md-sys-color-secondary)The container.
--md-comp-extended-fab-secondary-label-text-colorvar(--md-sys-color-on-secondary)The label and the icon, which follows it.
Tertiary (color)
--md-comp-extended-fab-tertiary-container-colorvar(--md-sys-color-tertiary)The container.
--md-comp-extended-fab-tertiary-label-text-colorvar(--md-sys-color-on-tertiary)The label and the icon, which follows it.
Sm (size)
--md-comp-extended-fab-small-container-shapevar(--md-sys-shape-corner-large)The corners.ExtendedFabSmallTokens.ContainerShape
Md (size)
--md-comp-extended-fab-medium-container-shapevar(--md-sys-shape-corner-large-increased)The corners.ExtendedFabMediumTokens.ContainerShape
Lg (size)
--md-comp-extended-fab-large-container-shapevar(--md-sys-shape-corner-extra-large)The corners.ExtendedFabLargeTokens.ContainerShape

Spec status

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

    Built

    Variant · Colors

  • Medium FAB

    Built

    Variant · Colors

  • Large FAB

    Built

    Variant · Colors

  • Small, medium and large extended FAB

    Built

    Variant · Extended

  • Color: primary, secondary, tertiary container

    Built

    Configuration · Color styles, Colors

  • Color: primary, secondary, tertiary

    Built

    Configuration · Color styles

  • Level 0 when nested in another component

    Built

    Use case · Elevation

  • Extended FAB collapsing to a FAB

    Built

    Use case · Extended collapse

  • Disappearing and reappearing on a page change

    Built

    Use case · Visibility

  • Lowered elevation

    Extension

    elevation="lowered" (level 1, hover 2, pressed 1) is Compose’s lowered elevation; the spec shows level 3, and level 0 when nested.

  • Links

    Extension

    href renders the FAB as an <a>.

  • Small FAB

    Not built

    Not recommended in M3 Expressive: use a larger size.

  • Surface colour styles

    Not built

    Still in the spec but no longer recommended for FABs and extended FABs.

  • Baseline extended FAB

    Not built

    Not recommended in M3 Expressive: use the small extended FAB.

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.

  • Fab, ExtendedFab: 18.8 kB

M3 Expressive specs

Sizes
default, md, lg
Shape
rounded-corner-large
Elevation
level3

Spec values and differences

  • Fab sizes are default / md / lg (56 / 80 / 96px); the small FAB is deprecated. ExtendedFab sizes are sm / md / lg (56 / 80 / 96px tall).
  • Corners are large (16px) / large-increased (20px) / extra-large (28px); icons follow the spec tokens, 24 / 28 / 32px. Extended FABs put 8 / 16 / 20px between icon and label.
  • elevation is default (level 3, hover 4, pressed 3), lowered (level 1, hover 2, pressed 1) or flat (level 0, for a FAB nested in another component such as the navigation rail). There is no press morph and no disabled state — the types enforce the latter.
  • Colour styles are primary-container (default), secondary-container, tertiary-container, primary, secondary and tertiary; Compose ships tokens only for the first two, the rest follow m3.material.io.
  • expanded animates the label's width in px between 0 and its measured width, as Compose interpolates the FAB's width, so expanding shows the fast spatial spring's overshoot; the label fades on the fast effects spring, and nothing uses transforms. Under reduced motion the width changes at once.
  • visible follows Compose's show / hide: the FAB expands from its centre (scale 0.2 → 1) on the fast spatial spring and fades on the fast effects spring. The scale is a transform set only while hidden or appearing, so it composes with Tailwind's translate-* and scale-* utilities.