Account

Buttons

Creative

Loading 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.

Terminal
npx @galactrex/ui add loading-button

Usage

Example
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.

See plans

Props

PropTypeDefaultDescription
childrenReactNode—Label.
onClick(e) => Promise<unknown> | unknown—The work; pending shows progress.
tone"solid" | "outline" | "ghost""solid"Look.
successLabel / errorLabelReactNode"Done" / "Failed"Result labels.
resultFornumber1600Ms a result stays.
...button propsButtonHTMLAttributes—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.