Floating action buttons: fab/1, one button (the canvas's solid ink button, or the retracting
pill) and fab_dial/1, a speed-dial that opens a column of actions.
<.fab id="new" label="Novo pedido" phx-click="new_order">
<:icon><.icon name="plus" size="md" /></:icon>
</.fab>
<.fab id="ask" label="Pergunte ao assistente" variant="pill" phx-click="open_assistant" />
<.fab id="help" label="Precisa de ajuda?" variant="pill" retract="auto" retract_after={6000} />
<.fab id="chat" label="Chat" variant="pill" retract="always" color="light" position="bottom-left" badge={3} />
<.fab_dial id="quick" label="Ações rápidas">
<:action label="Novo contato" phx-click="new_contact"><.icon name="user-plus" /></:action>
<:action label="Enviar arquivo" phx-click="upload"><.icon name="upload" /></:action>
</.fab_dial>Position
Both are fixed to the viewport corner (fixed, the default; --ledger-z-fab, 90, keeps them
under modals and drawers). fixed={false} leaves them absolute in the nearest positioned
ancestor, which is how the showcase demos show them inside a box. offset moves a button from
its corner, in pixels.
Hooks
LedgerUI.Fab(priv/static/ledger_ui/hooks/fab.js), only forretract="auto": expands the pill, retracts it afterretract_afterms or on scroll, expands it again on hover and focus.data-stateis kept across patches (keep-data-state).LedgerUI.FabDial(priv/static/ledger_ui/hooks/fab_dial.js): click toggles, Escape closes and returns focus, arrows/Home/End walk the actions, a click outside or focus leaving closes it.
Summary
Functions
Attributes
id(:string) (required)label(:string) (required) - Always rendered, and thearia-label.position(:string) - Defaults to"bottom-right". Must be one of"bottom-right","bottom-left","top-right", or"top-left".color(:string) - Defaults to"assistant". Must be one of"assistant","primary","dark", or"light".size(:string) - Defaults to"md". Must be one of"md", or"lg".variant(:string) - Defaults to"canvas". Must be one of"canvas", or"pill".offset(:integer) - Distance from the corner, in pixels. Defaults tonil.retract(:string) - Defaults to"hover". Must be one of"hover","auto","never", or"always".retract_after(:integer) - Milliseconds beforeretract="auto"retracts. Defaults to4000.expanded(:boolean) - Forces the pill open, whateverretractsays. Defaults tofalse.badge(:any) - A count or short text on the bubble's corner. Defaults tonil.fixed(:boolean) - Fixed to the viewport (false: absolute in its parent). Defaults totrue.type(:string) - Defaults to"button".disabled(:boolean) - Defaults tofalse.class(:any) - Defaults tonil.style(:string) - Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["href", "navigate", "patch", "method", "download", "target", "rel", "replace", "form", "name", "value"].
Slots
icon- The glyph (a sparkle by default).inner_block- Replaces the visible label text (labelstays thearia-label).
Attributes
id(:string) (required)label(:string) (required) - The button'saria-labeland the name of the menu.position(:string) - Defaults to"bottom-right". Must be one of"bottom-right","bottom-left","top-right", or"top-left".color(:string) - Kept for API parity withfab/1. Defaults to"primary". Must be one of"assistant","primary","dark", or"light".size(:string) - Kept for API parity withfab/1. Defaults to"md". Must be one of"md", or"lg".variant(:string) - Defaults to"canvas". Must be one of"canvas", or"pill".offset(:integer) - Defaults tonil.open(:boolean) - The initial state; after mount the hook owns it. Defaults tofalse.fixed(:boolean) - Fixed to the viewport (false: absolute in its parent). Defaults totrue.class(:any) - Defaults tonil.style(:string) - Defaults tonil.- Global attributes are accepted.
Slots
icon- The glyph of the button, a plus by default; it turns while open.action(required) - A mini action: the icon is its content. Accepts attributes:label(:string) (required)href(:string)navigate(:string)patch(:string)phx-click(:any)phx-target(:any)disabled(:boolean)class(:any)