Button
Six variants with spring press feedback. The loading state swaps the label for a spinner without changing width.
- Category: Inputs
- Licence: Free, MIT
- Built with: React 19, Tailwind CSS 4, Motion
- Dependencies: motion, clsx, tailwind-merge
Examples
Variants
Loading
Labels slide up and out as the spinner slides in.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "primary" | "secondary" | "outline" | "ghost" | "destructive" | "ember" | "primary" | |
size | "sm" | "md" | "lg" | "icon" | "md" | |
loading | boolean | false | Locks width, shows a spinner, sets aria-busy. |
...props | HTMLMotionProps<"button"> | — |
About Button
Button is the one you will use a hundred times, so it is built to feel right every time: it presses on a spring, holds its width while loading so the layout never jumps, and comes in primary, secondary, outline, ghost, destructive and accent variants.
Button is an input component for React 19, styled with Tailwind CSS 4 and animated with Motion. It drops into Next.js, Vite, Remix or Astro through the shadcn CLI as a single file you own.
When to use Button
- Primary calls to action on landing pages and forms.
- Toolbar and dialog actions in the secondary, outline and ghost styles.
- Async actions like Save or Send, where the loading state replaces the label with a spinner.
- Icon-only buttons in compact UIs with the icon size.
How it works
It is a Motion button, so it accepts every native button prop plus the variant, size and loading props. Loading swaps the label for a spinner with a slide, sets aria-busy and disables the button, while a hidden copy of the label keeps the width.
It is a real form control: it has an accessible name, works with the keyboard alone, shows a visible focus ring and announces its state to screen readers. With prefers-reduced-motion on, it holds still or settles instantly instead of animating.
Customizing Button
Every prop is documented in the API reference above with its type and default. The ones you will reach for first are listed here.
The Customize panel next to the preview lets you change size, disabled, variant live, and the Code tab updates to match, so the snippet you copy already carries your values.
- variant (default "primary").
- size ("sm" | "md" | "lg" | "icon", default "md").
- loading (boolean, default false): Locks width, shows a spinner, sets aria-busy.
2 examples on this page
- Variants.
- Loading: Labels slide up and out as the spinner slides in.
Goes well with Button
Button is already composed into 41 ready-made sections, so you can see it in context or install the whole block.
- Hero Ember: Hero section
- Hero Split: Hero section
- Hero Rotating: Hero section
- Hero Terminal: Hero section
- Range Slider: Six animated React range sliders on one accessible core: inline, tick, fluid, wave, bubble and ruler
- Switch: An animated React toggle switch whose thumb stretches when pressed, like a real switch
- Checkbox: An animated React checkbox: the check draws itself in, the box pops, indeterminate morphs to a dash
- Radio Group: An animated React radio group with roving focus and a highlight that glides between card options
- Input: An animated React text input with icons, a shake-once error and a success check that draws in
Install Button
npx shadcn@latest add https://charcoalui.com/r/button.jsonButton is free and MIT licensed. The command copies button.tsx into components/ui and installs clsx, tailwind-merge; you can also copy the source from the Code tab by hand.
It pairs well with Liquid Metal, a Pro piece: A ring of moving liquid metal around buttons, icons and badges: a wandering halo, a pool of reflected light, and a highlight that swings towards the cursor. Chromatic, silver and gold, plus metal text.
Frequently asked questions
- Can I use it as a link?
- Wrap the styles: pass the same variant classes to your router's Link, or render the button inside one. The visual system is plain Tailwind classes, so it transfers to any element.
- How do I install Button?
- Run npx shadcn@latest add https://charcoalui.com/r/button.json. The shadcn CLI copies button.tsx into components/ui and installs motion, clsx, tailwind-merge. You can also copy the source from this page by hand.
- Is Button free for commercial use?
- Yes. Button is MIT licensed: use it in any personal or commercial project and change it however you like.
- Does Button work with Next.js?
- Yes. It is a client component for React 19 styled with Tailwind CSS 4, so it works in the Next.js App Router and Pages Router, Vite, Remix and Astro.
- Can an AI coding agent install Button?
- Yes. Connect the Charcoal UI MCP server (https://charcoalui.com/mcp) to Claude Code, Cursor or any MCP client; get_component returns Button's props and source and get_install_command returns the exact command.