ActionButton
For save, retry, refresh, download or any other action worth reporting on. ActionButton runs a sync or async action, moves through ready → pending → success | error, blocks duplicate activation while pending, hands the result or thrown error to callbacks and snippets, and returns to ready after reset_ms (default 2000). reset_ms={0} keeps the terminal state until the next activation.
The button reserves the width of its widest label up front, so swapping Save for Saving… never shifts the layout.
States and labels
labels maps each of the four states to its text and icons to a glyph. Both are partial: a state missing from labels keeps its ACTION_BUTTON_LABELS default, one missing from icons shows no icon. Labels render as text, so markup in them shows literally: pass an icon for a glyph, or take over rendering with the children snippet.
bind:state (or on_state_change) exposes the current state, and on_success / on_error receive the resolved value or thrown error. The demo below fails every second run to show the error path and the reset_ms countdown back to ready.
Custom rendering
The children snippet receives { state, icon, text, disabled, result, error } and replaces the default icon-plus-text body, for markup, a spinner or the result itself. as swaps the underlying element when a <button> will not do.
CopyButton
CopyButton wraps ActionButton into a copy-to-clipboard control with bindable state, custom labels, on_copy_success/on_copy_error callbacks and reset_ms. This site mounts one in global mode, which adds a button to every code block matching global_selector (default pre > code).