Skip to content
EspañolEnglish
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.
  • corner chooses the corner and direction which way it opens (up, down, start or end); by default, towards the inside of the screen.
  • showLabels shows each action's name next to its icon (the default); with false, icon only and the name is given with aria-label.
  • Every action carries its label: it is required, because an icon alone gives no name.
  • open, defaultOpen and onOpenChange to 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.

PropTypeWhat it does
actionsrequiredreadonly SpeedDialAction[]—
labelrequiredstringThe name of the button and of the menu (“Create”). Required: the button is just an icon.
classNamestringMerged with the library classes; it does not replace them.
closeOnSelectbooleanCloses the fan when an action is chosen. Default, yes.
cornerFloatingCorner—
defaultOpenboolean—
directionSpeedDialDirectionWhich way it opens. By default, up in the bottom corners and down in the top ones.
iconReactNodeThe icon of the closed button. By default a “+” that rotates into a cross when it opens.
onOpenChange(open: boolean) => void—
openbooleanOpen, controlled from outside.
showLabelsbooleanShows 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: