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-buttonpnpm dlx mvpblocks add b-buttonyarn dlx mvpblocks add b-buttonbunx mvpblocks add b-buttonFile 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.96on pointer-down (and keyboardSpace/Enter) with a stiff640 / 38 / 0.85spring, releases back on pointer-up, and nudges down1pxto read as a real click. Locked (disabledorloading) buttons drop the press state entirely. - Hover lift: non-link variants rise
1pxon 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.65sease-[0.22, 1, 0.36, 1]while its opacity steps0.36 → 0.2 → 0on times[0, 0.2, 1]. Ripples are suppressed on link variants, while loading, and under reduced motion. - Link underline (
variant="link",linkUnderline="motion"): a greymuted-foreground/50baseline fills with a foreground bar that scales fromscaleX: 0to1from the left edge on a420 / 36 / 0.65spring. Thestaticmode swaps this for the shadcnhover:underline. - Loading: the label crossfades out (blur
3px, opacity0, scale0.96, drifting up) and the busy content enters on a softer280 / 30 / 0.98spring, while the icon slot rotates-56° → 0and dissolves between the icon and a spring-in spinner. The default spinner is a LucideLoader2withanimate-spin;loadingIconswaps it.aria-busyis set and ripples are suppressed for the duration. - Animate size: with
animateSize, aResizeObservermeasures the intrinsic content width and the surface springs tocontent + horizontal padding + borderon a420 / 34 / 0.9width spring — so constant controls likeContinue → Saving… → Savednever jump or clip. - Routed links: passing
hrefrenders an animated anchor instead of a button. Disabled and loading links usearia-disabled,tabIndex={-1}, and prevent the click; atargetthat opens a new tab gainsnoopener noreferrerautomatically. - 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