Skip to content
syntaqx

Components ยท Actions

Button

shadcn's Button with a loading state (a spinner over the label, and the button keeps its width) and shapes: slant leans it, and a new shape is one line.

Installation

npx shadcn@latest add https://www.syntaqx.com/r/button.json

Changes from shadcn

It installs over shadcn's Button and keeps its API, variants and data-slots, so code written for it keeps working. On top of that:

  • Its press, hover and open states are shadcn's radix-vega style: it presses down a pixel, and a button whose menu is open stays highlighted. Mark an icon with data-icon="inline-start" or "inline-end" to tighten the padding on that side.
  • A loading prop: the label stays in place but hidden, so the button keeps its width, with a spinner over it and aria-busy set.
  • A busy button doesn't fade the way a disabled one does.
  • A shape prop. default is shadcn's button, markup and all. slant leans the button at --button-slant (8.5deg if unset) and stands the label back up. Add a shape as one entry in shape; any shape but the default wraps the content in data-slot="button-label".

Examples

Sizes

Loading

Shapes

Every variant and size takes a shape; the default is shadcn's. slant leans the whole button, so its border, hover and focus ring lean with it, and stands the label back up. A shape is one entry in shape in buttonVariants, such as pill: "rounded-full". Any shape but the default wraps the content in data-slot="button-label", so a shape that transforms the button can undo it on the label with *:data-[slot=button-label]:.

Slant angle

Set --button-slant on a button, or once on :root to match a brand's own diagonal. This site sets it to its 8.5 degree tilt.

Optimistic UI

Trust the input: apply the change immediately, reconcile on response, and roll back visibly on failure. The button is never disabled mid-flight, and a request id makes only the latest click's response count, so rapid clicks don't fight.

Inspired by Linear and Superhuman

Destructive-action guards

Calibrate the friction to the blast radius. A dismiss should be one click; a drop-database should require typing the name. Don't make a delete feel like an unsubscribe, or an unsubscribe feel like a delete.

Inspired by GitHub and Stripe

No guard

Reversible, low blast radius: dismiss a notification.

Soft confirm

Reversible within a window: delete a draft.

Type to confirm

Irreversible, high blast radius: drop a database, delete an org.