Floating action button
A round button that floats over a view, in one of its corners, for the view's main action: create, compose, add. A label widens it into a pill. As a speed dial it opens a short list of related actions instead of doing one. Use one per view; for actions that belong to a row or a field, use a button beside them.
Install
npx shadcn@latest add @thrum-pro/floating-action-buttonThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Automatically installs icon plus from the icon set.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
FloatingActionButton: position | "bottom-right" | "bottom-left" | "top-right" | "top-left" | Default "bottom-right" | The corner of the nearest positioned ancestor it sits in, 16 pixels from both edges. In right-to-left text the sides swap. |
FloatingActionButton: size | "sm" | "md" | "lg" | Default "lg" | sm is 28 pixels tall, md 32, lg 40. Without a label it is a circle of that size. |
FloatingActionButton: label | ReactNode | – | Text after the icon. It widens the circle into a pill and is the button's name. |
FloatingActionButton: aria-label | string | – | The name of a button that shows only its icon. The type requires it when there is no label. |
FloatingActionButton: children | ReactNode | – | The icon: one inline SVG that draws with currentColor. The button sets its size: 16 pixels, 20 in lg. |
FloatingActionButton: className | string | – | Extra classes, merged last. fixed pins it to the window; static puts it back in the flow. |
FloatingActionButton: ...props | ComponentProps<"button"> | – | Every other button attribute and event handler is passed through. |
SpeedDial: open | boolean | – | Whether the actions are open, when the parent holds the state. Use it with onOpenChange. |
SpeedDial: defaultOpen | boolean | Default false | Whether the actions start open. |
SpeedDial: onOpenChange | (open: boolean) => void | – | Called when the actions open or close, whatever caused it. |
SpeedDial: sound | boolean | Default true | Play a soft sound on opening and closing and a click when an action is picked, if the visitor has sound on. |
SpeedDialTrigger | position, size, label, aria-label | – | The floating button that opens the actions. It takes the same props as FloatingActionButton. With no children it shows a plus that turns into a cross while open. |
SpeedDialContent: side | "top" | "bottom" | "left" | "right" | Default "top" | The side of the button the list opens on. It moves to the other side when there is no room. Set bottom for a button in a top corner. |
SpeedDialContent: align | "start" | "center" | "end" | Default "end" | Which edge of the button the list lines up with. Set start for a button in a left corner. |
SpeedDialContent: className | string | – | Extra classes for the list. It is at least 160 pixels wide. |
SpeedDialItem: onClick | (event) => void | – | Runs when the action is picked. The list then closes. |
SpeedDialItem: disabled | boolean | Default false | Dimmed, skipped by the arrow keys, and cannot be picked. |
SpeedDialItem: closeOnClick | boolean | Default true | Whether picking the action closes the list. |
Motion and sound
Motion
- Hover changes the background over 150 ms. A press scales the button to 97% and back.
- The list fades in and grows from 96% to full size over 150 ms, from the corner nearest the button. Closing plays the same change backwards.
- The plus turns 45 degrees into a cross over 150 ms while the list is open.
- Reduced motion: the list appears and leaves at once, and the plus turns without a transition.
Sound
- A soft rising tone when the actions open.
- A soft falling tone when they close without a pick.
- A click when an action is picked.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- The plain button is a native button. Its name is the label, or the aria-label, and the type refuses a button with neither.
- The speed dial follows the WAI-ARIA menu button pattern: the button has aria-haspopup and aria-expanded, the list has the menu role and each action is a menuitem.
- Focus moves into the list when it opens and back to the button when it closes. While it is open the rest of the page cannot be reached.
- The button is 40 pixels across by default and never under 28, above the 24 pixel minimum for pointer targets.
- It covers what is under it. Leave room at the end of a scrolling view, so the last row can be scrolled clear of the button.
- The button and the list are floating surfaces: under a glass material they turn translucent, with a tint that keeps the text at 4.5 to 1.
| Keys | Action |
|---|---|
| Tab | Focus the button. |
| Enter / Space | On a plain button: press it. On a speed dial: open the actions and move to the first one. |
| ↓ / ↑ | On the speed dial's button: open the actions on the first or the last one. Inside the list: move to the next or previous action. |
| Home / End | Move to the first or last action. |
| A letter | Move to the next action that starts with it. |
| Enter / Space | Pick the highlighted action. The list closes and focus returns to the button. |
| Esc | Close the list without picking. Focus returns to the button. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/floating-action-button.tsx- Packages
@base-ui/react@1.9.0- Brings along
- Sound engine
- Icons
plus
Changelog
- 1.0.0 · 2026-12-03First release.