Button
Buttons trigger actions. Use for primary, secondary, ghost, and tertiary (utility-only, neutral filled) actions with configurable appearance, intent, and size.
Overview
The catnip-button component renders a native button element with consistent styling. It supports leading/trailing icons, icon-only mode, semantic intent (default, danger), and an optional loading state (aria-busy + native disabled + catnip-button--loading class). Note: using the same disabled look for loading is interim until UX defines final loading visuals; you supply spinners or labels via slots or icons.
Appearance rules: tertiary requires purpose="utility"; otherwise the component renders as primary. size="xs" requires purpose="utility"; otherwise the button renders as s. intent="danger" is only supported with appearance primary or ghost; other combinations render as primary + danger. Invalid combinations log a dev-mode console warning.
selected: Only applies with purpose="utility" (e.g. utility toggle groups); sets aria-pressed and dedicated selected styles via catnip-button--selected (primary: filled pressed; other appearances: subtle fill + primary border).
Live example
Accessibility
- Native
<button>withdisabled— no redundantaria-disabled; the disabled attribute is enough for assistive technology (including whenloadingforces disabled). loading: setsaria-busy="true", uses nativedisabled(same asdisabledprop for interaction), and addscatnip-button--loading. Interim: this disabled look-and-feel for loading is provisional until UX signs off on final loading patterns; the accessible contract (aria-busy, no activation) should remain. Spinner/label visuals are yours (e.g.leftIconSlotwithcatnip-spinner).- Icon-only (no visible label): set
aria-labelso the control has an accessible name. In development, a console warning is logged if an icon-only button has noaria-label. type: defaults tobuttonso buttons inside forms do not accidentally submit; usesubmit/resetonly when intended.- Meet contrast requirements for text and icons on the button surface (WCAG AA).