Button
Displays a button or a link that looks like a button.
Installation
$ npx shadcn@latest add @constella/buttonUsage
import { Button } from "@/components/primitives/button";<Button variant="outline">Button</Button>Variant
Use the variant prop to set how much the button stands out. Use one primary per view.
Color
Use color="danger" for an action that deletes or destroys. Every variant takes it without changing its shape; primary draws the same tint as secondary.
<Button color="danger">Delete</Button><Button color="danger" variant="ghost">Delete</Button>Size
Use the size prop to change the size of the button.
<Button size="xs">Extra small</Button><Button size="sm">Small</Button><Button>Default</Button><Button size="lg">Large</Button>Icon Only
Use an icon-* size for a button with only an icon. Add an aria-label.
<Button size="icon" aria-label="Search"> <HugeiconsIcon icon={Search01Icon} size={sizes.icon} aria-hidden /></Button>With Icon
Add data-icon="inline-start" or data-icon="inline-end" to the icon for the correct spacing. Use sizes.iconXs at xs, sizes.iconSm at sm and sizes.icon otherwise.
<Button> <HugeiconsIcon icon={Add01Icon} size={sizes.icon} data-icon="inline-start" aria-hidden /> New project</Button>Corners
Buttons are pills by default. Use corners="rounded" for the theme's control corner, radii.sm.
<Button corners="rounded">Get started</Button>As Link
Use buttonStyles to make a link look like a button.
Don't use <Button render={<a />} nativeButton={false} /> for links. Base UI's Button always sets role="button", so screen readers announce it as a button, not a link.
import * as stylex from "@stylexjs/stylex";
import { buttonStyles } from "@/components/primitives/button";
<a href="/settings" {...stylex.props(buttonStyles({ variant: "outline" }))}> Settings</a>;Disabled
Use disabled when the action isn't available. It fades the button and shows a not-allowed cursor.
<Button disabled>Disabled</Button>Busy
Add aria-busy while something runs. It shows a busy cursor, so working reads differently from unavailable. What goes inside is up to you.
- With
disabled, it's loading: it fades less than disabled and can't be pressed twice. - Alone, it stays pressable at full strength, for a button that acts on the running work: press Generate, and the same button becomes Stop generating.
<Button aria-busy disabled> <Spinner data-icon="inline-start" /> Saving</Button><Button aria-busy={generating} onClick={() => setGenerating(!generating)}> {generating && <Spinner data-icon="inline-start" />} {generating ? "Stop generating" : "Generate"}</Button>API Reference
Button
Takes every prop of Base UI's Button, plus:
buttonStyles
Returns the button's styles for stylex.props. Takes variant, color, size and corners, with the same defaults.