Inputs
Button
Trigger actions with five visual variants, three sizes, leading and trailing icons, and a loading state.
<script>
import { Button } from "@codeatlasdev/ui";
</script>
<Button variant="filled" onclick={save}>Save</Button>
Secondary actions use tone="neutral". One brand filled button per card; the actions beside it (Edit, Snooze, Previous, Skip) are variant="outlined" or "ghost" with tone="neutral": --ca-text-primary label (--ca-text-secondary for ghost), --ca-outline-control border, --ca-action-hover / --ca-action-selected hover and pressed fills, and the same sizes, loading, disabled and focus ring. Never override .ca-btn colours from the app. IconButton takes the same tone on its outlined variant (its text variant is already neutral); extra attributes such as aria-expanded are forwarded, so both work as Popover triggers. Label and border contrast on the raised and overlay surfaces is measured for every preset in tests/contrast.test.ts.
On touch devices every size grows to a 44px target and presses scale down slightly, like a native control.
Variants
filled, glass (a tinted surface button that follows the theme: opaque under solid), outlined, ghost and destructive.
Reference #006 · Pick in the gallery
Code
Sizes
Reference #004 · Pick in the gallery
Code
With icons
Leading and trailing snippets.
Reference #002 · Pick in the gallery
Code
Loading
Swaps the leading icon for a spinner, sets aria-busy and blocks clicks while keeping the label.
Reference #003 · Pick in the gallery
Code
States
Disabled buttons, a destructive action and a link rendered as a button.
Reference #005 · Pick in the gallery
Code
Neutral tone
`tone="neutral"` on `outlined` and `ghost` (Button) and on `outlined` (IconButton): neutral label and border for a secondary action beside a brand `filled` one.
Reference #640 · Pick in the gallery
Code
Full width
fullWidth stretches the button to its container.
Reference #001 · Pick in the gallery
Code
Component tokens
Weight, gap, padding, ghost border and icon size set on one wrapper.
Reference #880 · Pick in the gallery
Code
Tokens
Weight, tracking, line-height, gap, padding and size are component tokens: set them on :root, a wrapper or ThemeOptions.components. Unset, a button draws what it always did; a size token wins over the all-sizes one (--ca-btn-lg-font-weight changes lg only).
- Every size:
--ca-btn-font-weight(500),--ca-btn-letter-spacing(--ca-label-tracking),--ca-btn-line-height(inherited),--ca-btn-gap(--ca-space-1-5). - One size,
--ca-btn-{sm,md,lg}-:height,padding-x,font-size,font-weight,letter-spacing. --ca-btn-ghost-border-width:0pxmakes a ghost button as wide as a text one.--ca-btn-disabled-bg: e.g.var(--ca-brand-fill).--ca-btn-touch-height,--ca-icon-btn-touch-size: thepointer: coarseminimum, 44px unless you set it.IconButton:--ca-icon-btn-size-{sm,md,lg}(32/40/48px) and--ca-icon-btn-font-weight.
Keyboard hint: trailingHint. Put a <Kbd> in trailing and add trailingHint: below md and on touch screens the slot is display: none, so it takes no space and the button is as wide as its label alone. Never hide .ca-btn__trailing with a media query in the app. Label start, hint end: align="between". With fullWidth (or a fixed width) the label stays at the start and trailing goes to the end; the loading spinner stays in the leading slot. Do not write justify-content: flex-start plus margin-left: auto on .ca-btn__trailing.
Responsive keyboard hint
`trailingHint` hides the `Kbd` below md and on touch, without leaving a gap.
Reference #901 · Pick in the gallery
Code
Align between
`align="between"`: label at the start, hint at the end; the spinner keeps its place.
Reference #902 · Pick in the gallery
Code
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'filled' | 'glass' | 'outlined' | 'ghost' | 'destructive' | 'filled' | Visual style. `filled` is the primary action; `glass` is a tinted surface button whose blur only shows under the `glass` and `frosted` styles. |
tone | 'brand' | 'neutral' | 'brand' | `'neutral'` draws `outlined` and `ghost` with neutral label, border and hover fills (adds `ca-btn--neutral`). Other variants ignore it. `IconButton` has the same prop for its `outlined` variant (new, adds `ca-icon-btn--outlined`). |
size | 'sm' | 'md' | 'lg' | 'md' | Height, padding and font size. |
disabled | boolean | false | Prevents interaction. |
loading | boolean | false | Shows a spinner in place of leading, sets aria-busy, blocks interaction and keeps the label. Adds ca-btn--loading. Screen readers hear "Finished loading" when it ends. |
type | 'button' | 'submit' | 'reset' | string | 'button' | Without href: the HTML button type (`submit` inside a `<form>` submits it). With href: the MIME type hint of the linked resource. |
form | string | – | Without href, the `id` of the `<form>` this button submits, for a button outside it: the footer of a `Dialog` (`actions`) or a sticky action bar. `formaction`, `name` and `value` are forwarded the same way. A link rejects them. |
fullWidth | boolean | false | Stretches the button to the width of its container. |
href | string | – | Renders an anchor styled as a button. The props then accept the anchor's attributes: download, rel, hreflang, ping, referrerpolicy. |
target | string | – | Anchor target, used with href. "_blank" adds rel="noopener noreferrer" to any rel you pass. |
children | Snippet | – | Button label. |
leading | Snippet | – | Content before the label. Replaced by a spinner while loading. |
trailing | Snippet | – | Content after the label. |
trailingHint | boolean | false | Marks `trailing` as a keyboard hint: hidden below `md` and under `(pointer: coarse)`, with no reserved gap (adds `ca-btn__trailing--hint`). |
align | 'center' | 'between' | 'center' | `'between'` pins the label to the start and `trailing` to the end (adds `ca-btn--between`). The loading spinner stays in the leading slot. |
onclick | (e: MouseEvent) => void | – | Click handler. Not called while disabled or loading. |
aria-label | string | – | Accessible name for icon-only buttons. |
class | string | – | Extra classes on the root element. |