Buttons
CreativeLoading Button
While the work runs it spins and refuses repeat clicks, then ticks for success or shakes for failure and returns. The width eases between states.
Install
Included with Creative: needs your API key. Initialize and log in once.
npx @galactrex/ui add loading-buttonUsage
import { LoadingButton } from "@/components/galactrex/loading-button";
<LoadingButton onClick={() => api.save(draft)}>Save draft</LoadingButton>Source
Installs to components/galactrex/loading-button.tsx, with the shared motion primitives beside it.
Source for this component comes with its plan. Install it with the command above, or open your licensed copy here.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Label. |
onClick | (e) => Promise<unknown> | unknown | — | The work; pending shows progress. |
tone | "solid" | "outline" | "ghost" | "solid" | Look. |
successLabel / errorLabel | ReactNode | "Done" / "Failed" | Result labels. |
resultFor | number | 1600 | Ms a result stays. |
...button props | ButtonHTMLAttributes | — | onClick, disabled, type and the rest. |
Variants
- Save. Await the request in onClick.
- Fails sometimes. Throw to show the error shake.
Accessibility
- aria-busy while working; results announced politely.
- Repeat clicks are ignored while busy.
Motion and reduced motion
- Layout animation for width, cross-fade for states, a short shake on error.
- Reduced motion: no shake or travel.