Android — Material 3
JS behaviour
FAB & FAB menu
The FAB in its four official sizes — small, medium, large, extended — and the FAB menu opening from it: items peek out with labels, the + rotates and the backdrop dims.
Real scenarios
The component as it is used in a product — not a specimen grid.
A FAB that composes
The extended FAB floats over the notes list in its primary-container colour. Tap it and a new note really lands in the list.
Notes
۳ یادداشتsmall · 40
medium · 56
large · 96
The FAB menu
Open the + and three labelled actions peek upward, the backdrop dims, and Escape or a tap outside closes it again.
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| size | px | '56 · 96 · 40' | Medium, large and small; extended grows with its label. |
| --m3fab-container | color | '#E8DEF8' | The FAB container colour; Material’s primary-container surface. |
| menu | state | 'closed' | data-open springs the menu; Escape and outside taps close it. |
Snippet
<div class="m3fab" data-open="false">
<div class="m3fab-actions">
<button class="m3fab-item"><span>عکس</span><i>…</i></button>
<button class="m3fab-item"><span>فایل</span><i>…</i></button>
</div>
<button class="m3fab m3fab-md" aria-expanded="false" aria-label="ساخت">
<svg class="m3fab-plus">+</svg>
</button>
</div>
<style>
.m3fab-md { inline-size: 56px; aspect-ratio: 1; border-radius: 16px;
background: #E8DEF8; color: #1D192B; box-shadow: 0 4px 8px 3px #00000026; }
.m3fab[data-open='true'] .m3fab-plus { rotate: 45deg; }
.m3fab-actions { display: grid; gap: 12px; place-items: end; opacity: 0; translate: 0 8px; }
.m3fab[data-open='true'] .m3fab-actions { opacity: 1; translate: 0 0; }
</style>