Skip to content

Components

Action Button

A button for one async action. Its arrow floats apart as a glass droplet; press it and the droplet melts into the body, and stays.

Markdown
glass-action-button-basic.tsx

Use it for

  • One async commit whose result belongs on the button: Deploy, Publish, Add to cart, Subscribe.
  • Actions that stay done: the merged "Deployed ✓" is the new state of the page.

Not for

  • Plain links and instant actions: use GlassButton.
  • Toggling back and forth between two states: use GlassTabs.
  • More than one per screen: the droplet is the kit's one gooey effect, keep it special.

Installation

Coming soon
npm install @vitrumui/react
No dependencies

Usage

app.tsx
import { GlassActionButton } from '@vitrumui/react/action-button'

<GlassActionButton
  material="tinted"
  className="bg-neutral-900 text-white"
  pendingLabel="Deploying"
  successLabel="Deployed"
  onAction={deploy} // return the promise
>
  Deploy
</GlassActionButton>

The flow

  • Idle. The arrow floats apart from the body as a separate glass droplet.
  • Press. The droplet stretches back on a gooey bridge and melts into the body.
  • Pending. One body; the label morphs to pendingLabel and a spinner turns where the arrow was, until the promise from onAction settles.
  • Success. Still one body: successLabel and a check that draws itself in. It stays merged, unless you set resetAfter.
  • Error. If onAction throws, the droplet splits off again and onActionError gets the error.

Examples

Coming soon

API reference

PropTypeDefault
children

The idle label, and the button's accessible name.

ReactNode—
onAction

Required. Runs on press; return a promise to stay pending until it settles.

() => unknown—
onActionError

Called when onAction throws; the button returns to idle.

(error) => void—
pendingLabel

Label while onAction runs.

ReactNodechildren
successLabel

Label after it succeeds.

ReactNodechildren
resetAfter

Milliseconds before splitting off again after a success. 0 stays merged.

number0
icon

The droplet's idle icon.

ReactNodearrow
material

As on GlassButton.

'clear' | 'tinted''clear'
size

Height 32, 40 or 48 px.

'sm' | 'md' | 'lg''md'
…rest

Passed to the <button> (not onClick: use onAction).

button attributes—

Accessibility

  • A real <button>; Enter and Space run the action.
  • Pending sets aria-busy, and pending or done sets aria-disabled instead of disabled, so focus stays on the button.
  • A role="status" region announces the pending and success labels.
  • With reduced motion the droplet and labels switch without animation.