Components

Button

The shadcn/ui Button, upgraded with Motion: a width-stable loading state, tactile press feedback and reduced-motion support — plus six animated blocks built on top of it.

  • Drop-in shadcn API
  • Motion
  • Keyboard & screen-reader friendly
  • prefers-reduced-motion

Installation

$ npx shadcn@latest add https://duskui.com/r/button.json

Already using shadcn/ui? This file replaces components/ui/button.tsx and keeps the same API, so existing buttons keep working.

Usage

save-button.tsx
import { Button } from "@/components/ui/button"

export function SaveButton() {
  const [saving, setSaving] = React.useState(false)

  return (
    <Button loading={saving} onClick={() => setSaving(true)}>
      Save
    </Button>
  )
}

Examples

Variants

All six shadcn variants plus soft, a tinted primary for secondary actions that still need the brand color.

Sizes

Text sizes sm, default, lg and square icon sizes. Always give icon-only buttons an aria-label.

With icons

Drop any Lucide icon in as a child. Icons are auto-sized, and a group class makes trailing arrows nudge on hover.

Loading

loading crossfades the label into a spinner without changing the width, so nothing around it jumps. Clicks are blocked, but the button stays focusable and announces aria-busy. Add loadingText to show a label next to the spinner.

As link

asChild merges the button styles onto its child, e.g. a Next.js Link.

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Status Button

Walks through idle → loading → success / error in place. The width eases between labels, the check mark draws itself and errors shake. Pair it with the useStatusAction hook to wire any async function.

$ npx shadcn@latest add https://duskui.com/r/status-button.json
PropTypeDefaultDescription
status"idle" | "loading" | "success" | "error""idle"Current state. Idle renders children.
labelsPartial<Record<status, ReactNode>>Saving / Saved / Try againLabels for the non-idle states.

Hold to Confirm

A safer alternative to a confirm dialog for destructive actions. A fill wipes across while held; releasing early springs it back. Works with mouse, touch, Space and Enter.

$ npx shadcn@latest add https://duskui.com/r/hold-to-confirm-button.json
PropTypeDefaultDescription
onConfirm() => void—Called once the hold completes.
holdDurationnumber1200Hold time in milliseconds.
fillClassNamestring"bg-[color-mix(…destructive 70%, black)] text-white"Classes for the fill layer. The default darkens the destructive color so white text stays readable.

Shimmer Button

A thin, faint sheen sweeps across on hover, or on a slow loop with idle. Best kept to one primary call to action per screen.

$ npx shadcn@latest add https://duskui.com/r/shimmer-button.json
PropTypeDefaultDescription
idlebooleanfalseSweep on a loop instead of only on hover.
intervalnumber4Seconds between idle sweeps.

Magnetic Button

Pulled slightly toward the cursor on a damped spring, with the label moving slightly further for depth. Mouse only; static for touch and reduced motion.

$ npx shadcn@latest add https://duskui.com/r/magnetic-button.json
PropTypeDefaultDescription
strengthnumber0.15How far the button follows the cursor (0–1).

Spotlight Button

A faint highlight tracks the cursor along the 1px border, with a barely visible tint on the surface. Uses motion values, so moving the mouse never re-renders React.

$ npx shadcn@latest add https://duskui.com/r/spotlight-button.json
PropTypeDefaultDescription
radiusnumber60Radius of the light in px.
colorstring"#ffffff"Any CSS color, mixed in at low opacity.

Copy Button

Copies text and morphs the icon into a check mark. It powers every copy button in these docs.

npx shadcn@latest add https://duskui.com/r/button.json
$ npx shadcn@latest add https://duskui.com/r/copy-button.json
PropTypeDefaultDescription
valuestring—Text written to the clipboard.
onCopied(value: string) => void—Called after a successful copy.
timeoutnumber1600How long the check stays, in ms.

API Reference

Accepts every native <button> prop. Also exports MotionButton (the Button with Motion props) and buttonVariants for styling other elements.

PropTypeDefaultDescription
variant"default" | "secondary" | "soft" | "outline" | "ghost" | "destructive" | "link""default"Visual style.
size"sm" | "default" | "lg" | "icon" | "icon-sm" | "icon-lg""default"Height and padding.
loadingbooleanfalseShows a spinner, blocks clicks, keeps width and focus.
loadingTextReactNode—Optional label next to the spinner.
loaderIconComponentType<{ className?: string }>Loader2Custom spinner icon.
asChildbooleanfalseRender the child element instead (Radix Slot). Loading is ignored.

Accessibility

  • While loading the button uses aria-disabled and aria-busy instead of disabled, so focus is never lost.
  • The spinner has a screen-reader label; status changes in Status Button are announced with aria-live.
  • Visible focus ring on keyboard focus only (focus-visible).
  • Movement is removed when the user prefers reduced motion; opacity fades remain.