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.jsonChanges 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
loadingprop: the label stays in place but hidden, so the button keeps its width, with a spinner over it andaria-busyset. - A busy button doesn't fade the way a disabled one does.
- A
shapeprop.defaultis shadcn's button, markup and all.slantleans the button at--button-slant(8.5deg if unset) and stands the label back up. Add a shape as one entry inshape; any shape but the default wraps the content indata-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.