Action button
Runs an action and shows how it went in place: a spinner, then a checkmark.
Installation
npm i @uisatin/uiimport { ActionButton } from '@uisatin/ui/action-button'About 15.5 kB of JavaScript, minified and gzipped, with what it imports (React aside). The stylesheet is one file for every component.
npx shadcn@latest add https://uisatin.dev/r/action-button.jsonAdds action-button.tsx, button.tsx, labels.tsx and spinner.tsx to components/ui.
First time with Satin? Set it up once, styles and fonts included, with the installation guide.
API Reference
The ActionButton component is a Button that runs onAction and shows its state in place: the label with an arrow, a spinner until the promise settles, then a checkmark. It takes every Button prop.
| Prop | Type | Default |
|---|---|---|
onAction | (event) => Promise<unknown> | — |
onClick | (event) => void | — |
variant | "primary""secondary""tertiary""inverse""destructive" | "primary" |
size | "xs""md""lg""xl" | "md" |
minLoading | number | 900 |
resetAfter | numbernull | 1800 |
trailingIcon | ReactNodenull | arrow |
state | "idle""loading""success" | — |
onStateChange | (state) => void | — |
onError | (error) => void | — |
Accessibility
A Button. While the action runs it has aria-busy and aria-disabled, keeps focus and ignores clicks; on success a polite live region says "Done" (done in SatinLabels). The spinner and checkmark are hidden. A failed action goes back to idle silently, so announce the error yourself.
| Key | Action |
|---|---|
| EnterorSpace | Runs onAction. Does nothing while busy or done. |
Something wrong or missing on this page?
Report a problemSuggest an improvement