Skip to content

Button

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">.

All variants
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' });
sm / md / lg
button({ label: 'Small', size: 'sm', variant: 'outline' });
button({ label: 'Medium', size: 'md', variant: 'outline' });
button({ label: 'Large', size: 'lg', variant: 'outline' });

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

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

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

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

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

Solid colorPalette
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:

Outline colorPalette
button({ label: 'Info', variant: 'outline', color: 'info' });
OptionTypeDefaultDescription
labelstringButton text (required).
hrefstringTarget URL — renders an <a> instead of <button>.
variant'solid' | 'subtle' | 'surface' | 'outline' | 'ghost' | 'plain''solid'Visual style.
size'sm' | 'md' | 'lg''md'Height and padding (2rem / 2.5rem / 3rem).
color'primary' | 'info' | 'success' | 'warning' | 'error' | 'idea''primary'Color palette from the kit’s semantic tokens.
iconstring''Raw SVG string before the label.
externalbooleanfalseWith href: opens the link in a new tab.
attrsRecord<string, string>Extra HTML attributes (e.g. data-cpd-drawer-trigger).
  • 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.