Fab <pm-fab>
Floating action button: the main action of a screen, fixed in a corner, with an optional menu of actions.
Variants
Set with the variant attribute.
variant="solid"variant="soft"variant="outline"Sizes
Set with the size attribute; controls keep touch-sized targets on phones.
size="sm"size="md"Tones
Set tone on the element, or data-tone on any ancestor to tone a whole area.
tone="accent"tone="secondary"tone="neutral"tone="success"tone="warning"tone="danger"tone="info"Overview
On its own it is one button (href makes it a link). Put buttons or links in it and it becomes a speed dial: pressing it opens them above it, the arrow keys move between them, and Escape, choosing one or pressing outside closes it. It stays clear of the home indicator and sits above the tab bar of a native phone layout. inline keeps it in the flow of the page.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
label | string | — | What the button does, e.g. "Create". It is the accessible name, and the visible text with extended. |
icon | string | — | Registered icon name (see registerIcons). Without one, a plus. |
extended | boolean | false | Show the label next to the icon. |
href | string | — | Make the button a link (when it has no actions). |
open | boolean | false | The speed dial is open. Setting it opens or closes it. |
position | 'end' | 'start' | 'center' | — | Corner of the screen: end (default), start or center. |
inline | boolean | false | Stay in the flow of the page instead of floating. |
size | 'sm' | 'md' | — | Size of the main button: sm or md (default). |
variant | 'solid' | 'soft' | 'outline' | — | Look of the main button (default solid). |
Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.
Events
| Event | React / Svelte prop | Description |
|---|---|---|
pm-toggle | onPmToggle | The speed dial opened or closed by the user. detail.open is the new state. |
pm-open | onPmOpen | The speed dial opened. |
pm-close | onPmClose | The speed dial closed. |
Slots
| Slot | Description |
|---|---|
(default) | Actions of the speed dial: <pm-button> elements, buttons or links. |
icon | Your own icon for the main button. |
CSS parts
| Part | Description |
|---|---|
::part(button) | The main button. |
::part(actions) | The list of actions. |
Methods
show(), hide(), toggle(), close()