Button

Action button for primary, secondary, inline, loading, and routed interactions.

Button

Action button for primary, secondary, inline, loading, and routed interactions.

Click the inline Continue button — a soft ripple blooms from the pointer and the surface springs down a hair. Set loading and the label crossfades into a spinning Loader2; set animateSize and the width springs between labels like Continue, Saving..., and Saved on one control.

Installation

Install the component with the Craft-UI Blocks CLI — it drops b-button.tsx into your project and wires up its runtime dependencies:

npx mvpblocks add b-button
pnpm dlx mvpblocks add b-button
yarn dlx mvpblocks add b-button
bunx mvpblocks add b-button

File Structure

The CLI saves the component to your project's components/ui folder:

Import it from @/components/ui/b-button.

Usage

"use client";

import { Button } from "@/components/ui/b-button";

export function ButtonPreview() {
  return (
    <p className="flex flex-wrap items-center justify-center gap-x-2 gap-y-2 text-balance font-medium text-lg text-neutral-800 leading-snug tracking-tight sm:text-xl dark:text-neutral-100">
      <span>When you are ready to ship with</span>
      <span className="font-medium text-foreground">default</span>
      <span>tap</span>
      <span className="inline-flex translate-y-px align-middle">
        <Button>Continue</Button>
      </span>
      <span>to finish.</span>
    </p>
  );
}

Pick a variant for the visual recipe and a size for the height and padding. Every button reads the labels above and below it, so it drops straight into copy, toolbars, and forms.

Theming

The button ships its own Iconiq token set, scoped to the component and mapped onto the standard shadcn variable names (--color-background, --color-foreground, --color-primary, and so on), so colors resolve with no separate theme install. In light mode the tokens are a white surface with #111111 ink; in dark mode they flip to a #111111 surface with #f6f3ec ink, driven entirely by dark: overrides on the same variables.

Each variant picks its surface from those tokens: default paints the primary color, outline sits on the page background with a hairline border, secondary uses a soft #eceff3 / #2a2a27 fill, ghost brightens an accent on hover, destructive is a soft destructive tint, and link strips the chrome to plain foreground text. The ripple color is derived per variant with color-mix(in oklch, …), so it always reads a touch lighter than the surface in both modes without hardcoding a second palette. Corners upgrade to a true squircle via corner-shape where the browser supports it, falling back to plain radii elsewhere.

Animations

  • Press: the surface springs to scale: 0.96 on pointer-down (and keyboard Space/Enter) with a stiff 640 / 38 / 0.85 spring, releases back on pointer-up, and nudges down 1px to read as a real click. Locked (disabled or loading) buttons drop the press state entirely.
  • Hover lift: non-link variants rise 1px on hover; the link variant instead animates its underline.
  • Ripple: a pointer ripple is drawn at the press point, sized to the farthest corner, capped at three concurrent ripples. It blooms on 0.65s ease-[0.22, 1, 0.36, 1] while its opacity steps 0.36 → 0.2 → 0 on times [0, 0.2, 1]. Ripples are suppressed on link variants, while loading, and under reduced motion.
  • Link underline (variant="link", linkUnderline="motion"): a grey muted-foreground/50 baseline fills with a foreground bar that scales from scaleX: 0 to 1 from the left edge on a 420 / 36 / 0.65 spring. The static mode swaps this for the shadcn hover:underline.
  • Loading: the label crossfades out (blur 3px, opacity 0, scale 0.96, drifting up) and the busy content enters on a softer 280 / 30 / 0.98 spring, while the icon slot rotates -56° → 0 and dissolves between the icon and a spring-in spinner. The default spinner is a Lucide Loader2 with animate-spin; loadingIcon swaps it. aria-busy is set and ripples are suppressed for the duration.
  • Animate size: with animateSize, a ResizeObserver measures the intrinsic content width and the surface springs to content + horizontal padding + border on a 420 / 34 / 0.9 width spring — so constant controls like Continue → Saving… → Saved never jump or clip.
  • Routed links: passing href renders an animated anchor instead of a button. Disabled and loading links use aria-disabled, tabIndex={-1}, and prevent the click; a target that opens a new tab gains noopener noreferrer automatically.
  • Reduced motion: every spring is replaced with a zero-duration opacity swap and presses, ripples, and the hover lift are disabled.

Props

Button

Prop

Type

buttonVariants

Prop

Type

Registry Bundle

Install the exact registry entry shown on the right when you want the component file and its declared runtime dependencies together. Dependencies: @base-ui/react, motion, class-variance-authority, lucide-react.

Embedded Iconiq theme tokens ship inside the component, so colors resolve without a separate theme install. This page documents the Base UI install only, because Radix UI does not ship a separate button primitive.

Contact

If you find any bug or issue, feel free to raise an issue.

Last updated on