All components (283)
Speed dial
Actions · SpeedDial
What it is and when to use it
A floating button that opens into a fan of actions: create a customer, an invoice or a notice from the same place. The “+” rotates into a cross when it opens and the actions come out of the button with a short fade.
When to use it
- Three to six “create” or “add” actions that must be at hand across the whole screen, especially on mobile.
cornerchooses the corner anddirectionwhich way it opens (up,down,startorend); by default, towards the inside of the screen.showLabelsshows each action's name next to its icon (the default); withfalse, icon only and the name is given witharia-label.- Every action carries its
label: it is required, because an icon alone gives no name. open,defaultOpenandonOpenChangeto open and close it from outside.
When not to
- A single action:
FloatingButton. - Actions that depend on a row or a block:
ActionMenu, in that block. - More than six: a proper menu, or a choosing screen.
Keyboard: the button announces that it opens a menu. Enter, Space or the arrow pointing outwards open it with focus on the first action; the arrow pointing to the button opens it with focus on the last. Inside, the arrows move through the actions wrapping around, Home and End go to the ends, Enter or Space run the action, Escape closes returning focus to the button and Tab closes and moves on. With the mouse, pressing outside closes it. In a right-to-left language the side arrows swap on their own.
Accessibility: it is a real menu: the button carries aria-haspopup="menu", aria-expanded and aria-controls; the fan is a role="menu" named like the button and each action a role="menuitem". Closed, the actions are not in the DOM: they are neither tabbed to nor read by the screen reader. A disabled action is skipped by the arrows. It does not show when printing.
Fine-tuning: the button and the actions are Button's (--amset-button-*); the shadow is the library's floating one. It is positioned with amset-speeddial.
In this sheet each story goes in its own frame: the fan stays in that frame's corner.
What it looks like
Pick an action from the menu in the corner.
<SpeedDial
label="Create"
actions={[
{ key: "cliente", label: "New customer", icon: <UserIcon />, onPress: crearCliente },
{ key: "factura", label: "New invoice", icon: <FileTextIcon />, onPress: crearFactura },
{ key: "aviso", label: "New alert", icon: <BellIcon />, onPress: crearAviso },
{ key: "nota", label: "New note", icon: <PencilIcon />, onPress: crearNota, disabled: true },
]}
corner="end-bottom"
direction="up"
defaultOpen
/>Props
Import it with import { SpeedDial } from '@amset/ui'. Required props are marked.
| Prop | Type | What it does |
|---|---|---|
actionsrequired | readonly SpeedDialAction[] | — |
labelrequired | string | The name of the button and of the menu (“Create”). Required: the button is just an icon. |
className | string | Merged with the library classes; it does not replace them. |
closeOnSelect | boolean | Closes the fan when an action is chosen. Default, yes. |
corner | FloatingCorner | — |
defaultOpen | boolean | — |
direction | SpeedDialDirection | Which way it opens. By default, up in the bottom corners and down in the top ones. |
icon | ReactNode | The icon of the closed button. By default a “+” that rotates into a cross when it opens. |
onOpenChange | (open: boolean) => void | — |
open | boolean | Open, controlled from outside. |
showLabels | boolean | Shows each action's name next to its icon. With `false`, icon only and the name is given with `aria-label`. Default, yes. |
size | "xs" | "sm" | "md" | "lg" | "xl" | — |
tone | "neutral" | "accent" | "secondary" | "tertiary" | "info" | "success" | "warning" | "error" | — |
variant | "solid" | "soft" | "outline" | — |
It also accepts the attributes of the element it renders: className, style, data-*, aria-* and its events.
In the test bench
Every state and variant, to try one at a time, on its page at storybook.amsetui.com:
