---
title: Button
description: Button — six variants, three sizes, link or native button.
---

`button()` builds a button: `variant` switches between Solid / Subtle /
Surface / Outline / Ghost / Plain, `size` between sm / md / lg. Pass `href`
to render an `<a>`, otherwise a native `<button type="button">`.

## Variants

```ts
button({ label: 'Solid', variant: 'solid' });
button({ label: 'Subtle', variant: 'subtle' });
button({ label: 'Surface', variant: 'surface' });
button({ label: 'Outline', variant: 'outline' });
button({ label: 'Ghost', variant: 'ghost' });
button({ label: 'Plain', variant: 'plain' });
```

## Sizes

```ts
button({ label: 'Small', size: 'sm', variant: 'outline' });
button({ label: 'Medium', size: 'md', variant: 'outline' });
button({ label: 'Large', size: 'lg', variant: 'outline' });
```

## Icon

Icons render before the label; any inline SVG string works.

```ts
button({
  label: 'Call us',
  variant: 'solid',
  icon: '<svg …>…</svg>', // any inline SVG string
});
```

## As a link

With `href` the button renders as an `<a>`; `external` opens a new tab.

```ts
button({ label: 'Get started', href: '/guides/example/', variant: 'solid' });
```

## Colors

`color` picks from the kit's semantic tokens (primary / info / success /
warning / error / idea). Solid renders the color with white contrast text.

```ts
button({ label: 'Info', variant: 'solid', color: 'info' });
button({ label: 'Success', variant: 'solid', color: 'success' });
button({ label: 'Warning', variant: 'solid', color: 'warning' });
button({ label: 'Error', variant: 'solid', color: 'error' });
button({ label: 'Idea', variant: 'solid', color: 'idea' });
```

Outline keeps the same palette:

```ts
button({ label: 'Info', variant: 'outline', color: 'info' });
```

## Props

<PropsTable
  labels={{ prop: 'Option', type: 'Type', default: 'Default' }}
  type={{
    label: { type: 'string', required: true, description: 'Button text.' },
    href: { type: 'string', description: 'Target URL — renders an <code>&lt;a&gt;</code> instead of <code>&lt;button&gt;</code>.' },
    variant: { type: "'solid' | 'subtle' | 'surface' | 'outline' | 'ghost' | 'plain'", default: "'solid'", description: 'Visual style.' },
    size: { type: "'sm' | 'md' | 'lg'", default: "'md'", description: 'Height and padding (2rem / 2.5rem / 3rem).' },
    color: { type: "'primary' | 'info' | 'success' | 'warning' | 'error' | 'idea'", default: "'primary'", description: "Color palette from the kit's semantic tokens." },
    icon: { type: 'string', default: "''", description: 'Raw SVG string before the label.' },
    external: { type: 'boolean', default: 'false', description: 'With <code>href</code>: opens the link in a new tab.' },
    attrs: { type: 'Record<string, string>', description: 'Extra HTML attributes (e.g. <code>data-cpd-drawer-trigger</code>).' },
  }}
/>

## Notes

- Hover darkens in light mode and lightens in dark mode (`color-mix`);
  focus shows a 2px ring (`--cpd-ring`); disabled renders at 50% opacity.
- Radius `0.375rem`; weight 600; `line-height: 1`.
