FAB
ExpressiveA screen's single most important action, as an icon or an extended label.
import { Fab, ExtendedFab } from '@windmorph/react';Props
Fab 23 props
The icon. Hidden from assistive tech;
aria-labelnames the FAB.Container size:
default(56px),md(medium, 80px) orlg(large, 96px). The small FAB is deprecated in M3 Expressive.Shows
aria-labelin 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 ownTooltipTrigger.colortype"primary-container" | "secondary-container" | "tertiary-container" | "primary" | "secondary" | "tertiary"default"primary-container"The colour style: a container colour or its solid form.
defaultis level 3 (hover 4);loweredis level 1 (hover 2), for FABs on surfaces that already sit above the page;flatis level 0, for a FAB nested in another component such as the navigation rail.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.Plays the appearing animation when the FAB mounts. Change the FAB's
keyon a page or tab change to replay it.Ref to the root element: the
<button>, or the<a>withhref.The value a submit button sends with its form, under its
name. On a toggle (toggle) it's astringnaming the button in a selection group instead, required to take part in the group's selection.The element is being dragged (e.g. a card picked up to move it): sets
data-draggedfor the dragged state layer. A consumer's owndata-draggedattribute counts too.Don't move focus to the element on press (set by menu triggers).
The element rendered: a native
<button>.Renders a link. Navigation goes through React Aria's
RouterProviderwhen one is set.
Text
The FAB's accessible name, also shown in its tooltip. Required without
aria-labelledby.The id of an element that names the FAB, instead of
aria-label.
Classes for each part, by slot.
classNames.rootis merged withclassName.Inline styles for the root element.
Classes for the root element, merged with
classNames.root; consumer classes win.
Handler that is called when the press is released over the target.
Handler that is called when a press interaction starts.
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
Handler that is called when the press state changes.
Handler that is called when a press is released over the target, regardless of whether it started on the target or not.
Also accepts every <a> or <button> attribute.
ExtendedFab 25 props
childrentypestring | number | bigint | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...>RequiredThe visible label; it also names the FAB, including while collapsed.
Container height and label size: small (56px), medium (80px) or large (96px).
Leading icon. Needed for the collapsed state, which shows the icon only.
Shows the label. Collapsing animates the FAB to a square showing only the icon (e.g. while the page scrolls).
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 ownTooltipTrigger.colortype"primary-container" | "secondary-container" | "tertiary-container" | "primary" | "secondary" | "tertiary"default"primary-container"The colour style: a container colour or its solid form.
defaultis level 3 (hover 4);loweredis level 1 (hover 2), for FABs on surfaces that already sit above the page;flatis level 0, for a FAB nested in another component such as the navigation rail.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.Plays the appearing animation when the FAB mounts. Change the FAB's
keyon a page or tab change to replay it.Ref to the root element: the
<button>, or the<a>withhref.The value a submit button sends with its form, under its
name. On a toggle (toggle) it's astringnaming the button in a selection group instead, required to take part in the group's selection.The element is being dragged (e.g. a card picked up to move it): sets
data-draggedfor the dragged state layer. A consumer's owndata-draggedattribute counts too.Don't move focus to the element on press (set by menu triggers).
The element rendered: a native
<button>.Renders a link. Navigation goes through React Aria's
RouterProviderwhen one is set.
Text
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.
The id of an element that names the FAB instead of its label.
Classes for each part, by slot.
classNames.rootis merged withclassName.The FAB element itself; merged with
className.Inner wrapper around the icon and label.
The leading icon.
The label's clipping wrapper, which collapses with the FAB.
The label text.
The built-in plain tooltip shown while collapsed (
tooltip).
Inline styles for the root element.
Classes for the root element, merged with
classNames.root; consumer classes win.
Handler that is called when the press is released over the target.
Handler that is called when a press interaction starts.
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
Handler that is called when the press state changes.
Handler that is called when a press is released over the target, regardless of whether it started on the target or not.
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.
| Variable | Default | Paints | Compose |
|---|---|---|---|
| Primary-container (color) | |||
--md-comp-fab-primary-container-container-color | var(--md-sys-color-primary-container) | The container. | FabPrimaryContainerTokens.ContainerColor |
--md-comp-fab-primary-container-icon-color | var(--md-sys-color-on-primary-container) | The icon. | FabPrimaryContainerTokens.IconColor |
| Secondary-container (color) | |||
--md-comp-fab-secondary-container-container-color | var(--md-sys-color-secondary-container) | The container. | FabSecondaryContainerTokens.ContainerColor |
--md-comp-fab-secondary-container-icon-color | var(--md-sys-color-on-secondary-container) | The icon. | FabSecondaryContainerTokens.IconColor |
| Tertiary-container (color) | |||
--md-comp-fab-tertiary-container-container-color | var(--md-sys-color-tertiary-container) | The container. | |
--md-comp-fab-tertiary-container-icon-color | var(--md-sys-color-on-tertiary-container) | The icon. | |
| Primary (color) | |||
--md-comp-fab-primary-container-color | var(--md-sys-color-primary) | The container. | |
--md-comp-fab-primary-icon-color | var(--md-sys-color-on-primary) | The icon. | |
| Secondary (color) | |||
--md-comp-fab-secondary-container-color | var(--md-sys-color-secondary) | The container. | |
--md-comp-fab-secondary-icon-color | var(--md-sys-color-on-secondary) | The icon. | |
| Tertiary (color) | |||
--md-comp-fab-tertiary-container-color | var(--md-sys-color-tertiary) | The container. | |
--md-comp-fab-tertiary-icon-color | var(--md-sys-color-on-tertiary) | The icon. | |
| Default (size) | |||
--md-comp-fab-container-shape | var(--md-sys-shape-corner-large) | The corners. | FabBaselineTokens.ContainerShape |
| Md (size) | |||
--md-comp-fab-medium-container-shape | var(--md-sys-shape-corner-large-increased) | The corners. | FabMediumTokens.ContainerShape |
| Lg (size) | |||
--md-comp-fab-large-container-shape | var(--md-sys-shape-corner-extra-large) | The corners. | FabLargeTokens.ContainerShape |
| Variable | Default | Paints | Compose |
|---|---|---|---|
| Primary-container (color) | |||
--md-comp-extended-fab-primary-container-container-color | var(--md-sys-color-primary-container) | The container. | |
--md-comp-extended-fab-primary-container-label-text-color | var(--md-sys-color-on-primary-container) | The label and the icon, which follows it. | |
| Secondary-container (color) | |||
--md-comp-extended-fab-secondary-container-container-color | var(--md-sys-color-secondary-container) | The container. | |
--md-comp-extended-fab-secondary-container-label-text-color | var(--md-sys-color-on-secondary-container) | The label and the icon, which follows it. | |
| Tertiary-container (color) | |||
--md-comp-extended-fab-tertiary-container-container-color | var(--md-sys-color-tertiary-container) | The container. | |
--md-comp-extended-fab-tertiary-container-label-text-color | var(--md-sys-color-on-tertiary-container) | The label and the icon, which follows it. | |
| Primary (color) | |||
--md-comp-extended-fab-primary-container-color | var(--md-sys-color-primary) | The container. | |
--md-comp-extended-fab-primary-label-text-color | var(--md-sys-color-on-primary) | The label and the icon, which follows it. | |
| Secondary (color) | |||
--md-comp-extended-fab-secondary-container-color | var(--md-sys-color-secondary) | The container. | |
--md-comp-extended-fab-secondary-label-text-color | var(--md-sys-color-on-secondary) | The label and the icon, which follows it. | |
| Tertiary (color) | |||
--md-comp-extended-fab-tertiary-container-color | var(--md-sys-color-tertiary) | The container. | |
--md-comp-extended-fab-tertiary-label-text-color | var(--md-sys-color-on-tertiary) | The label and the icon, which follows it. | |
| Sm (size) | |||
--md-comp-extended-fab-small-container-shape | var(--md-sys-shape-corner-large) | The corners. | ExtendedFabSmallTokens.ContainerShape |
| Md (size) | |||
--md-comp-extended-fab-medium-container-shape | var(--md-sys-shape-corner-large-increased) | The corners. | ExtendedFabMediumTokens.ContainerShape |
| Lg (size) | |||
--md-comp-extended-fab-large-container-shape | var(--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.
| Item | Status | Details |
|---|---|---|
| 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. |
FAB
BuiltVariant · Colors
Medium FAB
BuiltVariant · Colors
Large FAB
BuiltVariant · Colors
Small, medium and large extended FAB
BuiltVariant · Extended
Color: primary, secondary, tertiary container
BuiltConfiguration · Color styles, Colors
Color: primary, secondary, tertiary
BuiltConfiguration · Color styles
Level 0 when nested in another component
BuiltUse case · Elevation
Extended FAB collapsing to a FAB
BuiltUse case · Extended collapse
Disappearing and reappearing on a page change
BuiltUse case · Visibility
Lowered elevation
Extensionelevation="lowered"(level 1, hover 2, pressed 1) is Compose’s lowered elevation; the spec shows level 3, and level 0 when nested.Links
Extensionhrefrenders the FAB as an<a>.Small FAB
Not builtNot recommended in M3 Expressive: use a larger size.
Surface colour styles
Not builtStill in the spec but no longer recommended for FABs and extended FABs.
Baseline extended FAB
Not builtNot 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
Fabsizes are default / md / lg (56 / 80 / 96px); the small FAB is deprecated.ExtendedFabsizes 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.
elevationisdefault(level 3, hover 4, pressed 3),lowered(level 1, hover 2, pressed 1) orflat(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,secondaryandtertiary; Compose ships tokens only for the first two, the rest follow m3.material.io. expandedanimates 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.visiblefollows 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 atransformset only while hidden or appearing, so it composes with Tailwind'stranslate-*andscale-*utilities.