Floating Action Button (FAB) component with optional speed-dial.
Follows the Material Design / shadcn/ui FAB pattern adapted for Phoenix LiveView. Supports a simple single-button form and a speed-dial form with a main trigger button and one or more action items.
Simple button
<.float_button icon="plus" on_click="new_item" aria_label="Create new item" />Speed dial
<.float_button position={:bottom_right}>
<:main icon="menu" aria_label="Actions" />
<:item icon="edit" on_click="edit" label="Edit" />
<:item icon="share" on_click="share" label="Share" />
</.float_button>Positions
| Atom | CSS classes |
|---|---|
:bottom_right | bottom-6 right-6 |
:bottom_left | bottom-6 left-6 |
:top_right | top-6 right-6 |
:top_left | top-6 left-6 |
Theme tokens
bg-primary/text-primary-foreground— main button backgroundbg-secondary/text-secondary-foreground— speed-dial item buttonshover:bg-primary/90/hover:bg-secondary/90— hover statesshadow-lg/shadow— elevationfocus-visible:ring-ring— keyboard focus ring
Summary
Functions
Renders a Floating Action Button (FAB).
Functions
Renders a Floating Action Button (FAB).
When neither main nor item slots are provided, renders a simple
circular button fixed to the specified corner of the viewport.
When main or item slots are provided, renders a speed-dial: a
vertically stacked group of action items revealed above the main trigger
button.
Examples
<%!-- Simple FAB --%>
<.float_button icon="plus" on_click="new_item" aria_label="Create new item" />
<%!-- Top-left FAB --%>
<.float_button icon="plus" on_click="new_item" position={:top_left} />
<%!-- Speed-dial FAB --%>
<.float_button position={:bottom_right}>
<:main icon="menu" aria_label="Actions" />
<:item icon="edit" on_click="edit" label="Edit" />
<:item icon="share" on_click="share" label="Share" />
</.float_button>Attributes
id(:string) - Element ID used to wire up speed-dial toggle targets. Must be unique per page. Defaults to"float-btn".icon(:string) - Lucide icon name to render inside the simple button (e.g."plus","menu"). Defaults tonil.on_click(:string) - LiveView event name passed tophx-click. Defaults tonil.aria_label(:string) - Accessible label for the button; used by screen readers. Defaults to"Action".position(:atom) - Fixed position of the FAB in the viewport. Defaults to:bottom_right. Must be one of:bottom_right,:bottom_left,:top_right, or:top_left.class(:string) - Additional CSS classes merged viacn/1(last wins). Defaults tonil.
Slots
main- Main trigger button for speed-dial mode. Provide:iconand:aria_labelattrs. Accepts attributes:icon(:string) - Lucide icon name for the main trigger button.aria_label(:string) - Accessible label for the main trigger button.
item- Speed-dial action item. Provide:icon,:on_click, and:labelattrs. Accepts attributes:icon(:string) - Lucide icon name for the item button.on_click(:string) - LiveView event name passed tophx-clickfor this item.label(:string) - Visible label text rendered beside the item button.