Use one FAB for the primary action, or a FAB menu for related labelled actions. The menu opens on click and keeps ordinary Tab navigation.
See FAB menu for markup and migration guidance for removed FAB variants and speed dials.
FAB sizes
Add circle extra (or its alias
circle large) to make a FAB. It is 56dp, with 16dp corners, a
primary-container fill and elevation 3. Put the medium and large size classes
alongside the extra. The corner grows with the
container, so a bigger FAB is not a scaled-up copy of the default.
56dp
medium80dp
large96dp
<button type="button" class="circle extra" aria-label="Add">
<span class="material-symbols" aria-hidden="true">add</span>
</button>
<button type="button" class="circle extra medium" aria-label="Add">
<span class="material-symbols" aria-hidden="true">add</span>
</button>
<button type="button" class="circle extra large" aria-label="Add">
<span class="material-symbols" aria-hidden="true">add</span>
</button>
| Size | Class | Container | Corner | Icon |
|---|---|---|---|---|
| Default | circle extra | 56dp | 16dp | 24dp |
| Medium | circle extra medium | 80dp | 20dp | 26dp |
| Large | circle extra large | 96dp | 28dp | 36dp |
The large size needs the extra, because
circle large on its own is the alias for the default
56dp FAB and keeps that meaning.
On an <a>, add button, because the size
classes only match button or a.button.
<a class="button circle extra medium" href="/new" aria-label="Add">
<span class="material-symbols" aria-hidden="true">add</span>
</a>
For a one-off size, reset these four custom properties instead of writing new rules. Each size class sets the same four.
| Token | Default |
|---|---|
--md-comp-fab-container-height | 56px |
--md-comp-fab-container-width | 56px |
--md-comp-fab-container-shape | 16px |
--md-comp-fab-icon-size | 24px |
Extended FAB
Add extend small for the extended FAB, an icon and a label in a
56dp container with 16dp corners and 8dp between the two. Wrap the
label in its own <span>. The order of the two spans
sets the placement, and the wrapper triggers the 16dp leading inset.
extend small56dp
extend medium80dp
extend large96dp
extend smalltrailing icon
<button type="button" class="extend small">
<span class="material-symbols" aria-hidden="true">add</span><span>Create</span>
</button>
<button type="button" class="extend medium">
<span class="material-symbols" aria-hidden="true">add</span><span>Create</span>
</button>
The size axis is small, medium and
large, and the label role grows with the container:
title-medium, title-large,
headline-small. extend small is 56dp on a
symmetric 16dp inset. Always specify a size, because the sizeless
baseline extended FAB has been removed.
Set the container colour with a role class rather than a value.
primary-container is the default, and
secondary-container and tertiary-container
are the other two. Each class sets the container and the label
colour together, so the hover and focus state layers follow the
role.
primary-container
secondary-container
tertiary-container
<button type="button" class="extend small secondary-container">
<span class="material-symbols" aria-hidden="true">edit</span><span>Compose</span>
</button>
| Token | Default |
|---|---|
--md-comp-extended-fab-container-height | 56px (80px medium, 96px large) |
--md-comp-extended-fab-container-shape | 16px (20px medium, 28px large) |
--md-comp-extended-fab-icon-size | 24px (28px medium, 36px large) |
--md-comp-extended-fab-leading-space | 16px (26px medium, 28px large) |
--md-comp-extended-fab-icon-label-space | 8px (12px medium, 16px large) |
--md-comp-extended-fab-trailing-space | 16px (26px medium, 28px large) |
--md-comp-extended-fab-container-color | --md-sys-color-primary-container |
--md-comp-extended-fab-label-text-color | --md-sys-color-on-primary-container |
Migration
Replace .fab and .fixed-action-btn speed-dial wrappers with .fab-menu and visible labels on each action. This requires updating the markup, not just renaming the wrapper.
Remove direction, hoverEnabled, toolbarEnabled, their markup switches and speed-dial-only token overrides. Hover opening and FAB-to-toolbar expansion have been removed. Use the toolbar component for persistent commands.
Replace circle extra small with circle extra for the current 56dp FAB. Replace sizeless extend with extend small, or choose medium or large. The small extended FAB remains supported. Replace surface color classes on FABs with primary-container, secondary-container or tertiary-container and the matching on-*-container-text for icon-only FABs. General surface utilities remain available for other components.
Initialization
Expressive.AutoInit() initializes .fab-menu. To initialize it yourself, add no-autoinit. There are no component-specific options.
const instance = Expressive.FloatingActionButton.init(document.querySelector(".fab-menu.no-autoinit"));
Methods
All methods are called on the plugin instance. You can get the instance like this:
const instance = Expressive.FloatingActionButton.getInstance(elem);
.open();
Opens the FAB menu.
instance.open();
.close();
Closes the FAB menu.
instance.close();
.destroy();
Destroy the plugin instance and detach its event handlers.
instance.destroy();
Properties
| Name | Type | Description |
|---|---|---|
el |
Element | The DOM element the plugin was initialized with. |
options |
Object | The options the instance was initialized with. |
isOpen |
Boolean | Whether the FAB menu is open. |