Message 1
Message 2
Message 3
Message 4
Message 5
Message 6
Message 7
Message 8
A FAB represents the most important action on a screen, and an extended FAB adds a text label.
<md-gb-fab aria-label="Compose">
<md-gb-icon>edit</md-gb-icon>
</md-gb-fab>Install with shadcn/ui: npx shadcn@latest add https://material-web.dev/3.0/r/md-fab.json (setup)
A FAB holds an icon in its default slot. Set label to make it an extended FAB.
<md-gb-fab aria-label="Share">
<md-gb-icon>share</md-gb-icon>
</md-gb-fab>Set label for an extended FAB. The label is its accessible name.
<md-gb-fab label="Compose">
<md-gb-icon>edit</md-gb-icon>
</md-gb-fab>An extended FAB is the only FAB that can leave out its icon.
<md-gb-fab label="Reroute"></md-gb-fab>Set color to primary, primary-container (default), secondary, secondary-container, tertiary or tertiary-container.
<md-gb-fab color="primary-container" aria-label="Add">
<md-gb-icon>add</md-gb-icon>
</md-gb-fab>
<md-gb-fab color="secondary-container" aria-label="Add">
<md-gb-icon>add</md-gb-icon>
</md-gb-fab>
<md-gb-fab color="tertiary-container" aria-label="Add">
<md-gb-icon>add</md-gb-icon>
</md-gb-fab>Set size to md or lg. The default is the standard FAB. sm is a 40dp FAB that the spec no longer recommends.
<md-gb-fab aria-label="Add">
<md-gb-icon>add</md-gb-icon>
</md-gb-fab>
<md-gb-fab size="md" aria-label="Add">
<md-gb-icon>add</md-gb-icon>
</md-gb-fab>
<md-gb-fab size="lg" aria-label="Add">
<md-gb-icon>add</md-gb-icon>
</md-gb-fab>Set expanded="false" to collapse an extended FAB to an icon-only FAB. Set the expanded property to change it later.
<md-gb-fab label="Compose" expanded="false">
<md-gb-icon>edit</md-gb-icon>
</md-gb-fab>Set scroll-target to the id of a scrolling container, or window. The FAB collapses while it scrolls down and expands while it scrolls up. A cancelable toggle event fires first.
Message 1
Message 2
Message 3
Message 4
Message 5
Message 6
Message 7
Message 8
<div id="content">
<p>Message 1</p>
<p>Message 2</p>
<p>Message 3</p>
<p>Message 4</p>
<p>Message 5</p>
<p>Message 6</p>
<p>Message 7</p>
<p>Message 8</p>
<md-gb-fab label="Compose" scroll-target="content">
<md-gb-icon>edit</md-gb-icon>
</md-gb-fab>
</div>#content {
inline-size: 100%;
block-size: 240px;
overflow: auto;
}
md-gb-fab {
position: sticky;
inset-block-end: 16px;
}aria-label that describes its action, such as "Compose a new message".label as its name, also while collapsed. Add aria-label only for more context.tooltip="false" to turn it off.setupScrollPadding() from appbar/scroll-padding.js.134 of 377 buildable spec units are tested, 40 are excluded with a written reason and 0 are uncovered (the target is 0). 65 of 65 token declarations match the spec (100%).
floating-action-button on m3.material.io (opens in a new tab) extended-fab on m3.material.io (opens in a new tab) How compliance is measured
The component’s own CSS and JavaScript rely only on web platform features that are Baseline widely available: it works in Chrome 124, Edge 124, Firefox 125, Safari 17.4 and later.
Newer features it uses where the browser has them (progressive enhancements):
Browser support Learn more about Baseline (opens in a new tab)
Roles the component renders: button (opens in a new tab).
Follows the WAI-ARIA Authoring Practices: Button (opens in a new tab).
5 rendered states run through axe-core and the WAI-ARIA 1.3 role and attribute rules in a real browser, with no known gaps.
WAI-ARIA 1.3 (opens in a new tab) ARIA Authoring Practices (opens in a new tab) Accessibility
Audits under 90:
Lighthouse 12.8.2 (desktop, 2026-11-08) on the component alone: its first example on a page of its own, without this site's shell. The modules are the development build (not bundled or minified), so the performance score is indicative.
A Material Design component.
| Property | Attribute | Type | Default |
|---|---|---|---|
color |
color |
FabColor |
'primary-container' |
expandedWhether the extended FAB shows its label. When false, the label collapses and the FAB becomes an icon-only FAB. Set the attribute to expanded="false" to collapse it from markup. |
expanded |
boolean |
true |
labelThe extended FAB's label. Without one, the FAB is icon-only. |
label |
string |
'' |
scrollTargetOpt-in: the id of a scroll container (in the same root), or window. The FAB collapses while it scrolls down and expands while it scrolls up. |
scroll-target |
string |
'' |
sizeThe size. With a label, default, md and lg are the small, medium and large extended FABs. sm is the small (40dp) icon-only FAB, which the spec no longer recommends. |
size |
FabSize |
'default' |
tooltipShows a tooltip with the FAB's name (the label, else aria-label) on hover and keyboard focus. On by default for an icon-only FAB, whose icon has no visible text (floating-action-button.md: on web, a FAB should display a tooltip with its text label); tooltip="false" turns it off. |
tooltip |
boolean |
true |
| Slot | Description |
|---|---|
| default | The icon. Text placed here is shown but does not collapse; use label for an extended FAB. |
| Part | Description |
|---|---|
::part(fab) |
The FAB's root element. |
::part(label) |
The extended FAB's label. |
| Property | Description |
|---|---|
--container-color |
|
--container-elevation |
|
--container-height |
|
--container-shape |
|
--container-width |
|
--icon-color |
|
--icon-label-space |
|
--icon-size |
|
--label-text |
|
--label-text-axes |
|
--label-text-color |
|
--label-text-tracking |
|
--leading-space |
|
--trailing-space |
Changes apply to this site and its demos, and are remembered in this browser.
Your browser did not offer to install the docs as an app. Install them from the browser instead: