Buttons
The button element is styled by the element selector in wckd-ui.css, do not add .button on native buttons. Use .button on other hosts (usually an a.button link) so they share the same layout, hover, active, and focus behaviour. Default sizing uses font-size: inherit, min-height: 2.75rem (44px), flex alignment, and column-gap for label plus icon. Optional .size-xxs through .size-xxl step height and type. Modifiers .outline, .text, .size-*, and palette swatches work on either button or .button. Filled default uses --button-bg and --button-text; .icon-button is a 44px square (36px / 60px with .size-s / .size-l).
Download & setup
Start with the package download and setup steps in Get Started, then use the style guide for utility and token references while implementing this component.
Default implementation
Native button and link as button
Use <button type="button"> for actions (omit the redundant .button class). Use <a class="button"> when you need navigation with button chrome.
Markup
<button type="button">Save</button>
<a class="button" href="#">Continue</a>
Configuration options
Start from the default implementation, then apply one of these intent-driven variations based on your content and interaction goals.
Label and icon
Put the icon in <span class="wckd-icon"> (or your own wrapper); default flex layout and gap space it from the copy. wckd-icon sizes from its container, so you do not need size-* on the icon when the button or parent is already size-s and up. For a trailing icon, add .icon-right to the control.
Markup
<button type="button">
<span class="wckd-icon" aria-hidden="true">
<svg ...></svg>
</span>
New item
</button>
<button type="button" class="icon-right outline size-s">Next
<span class="wckd-icon" aria-hidden="true"><svg ...></svg></span>
</button>
Outline and text
.outline is border-only on a transparent track; hovers and active states keep the background transparent. .text uses the same colours and hover as links (--link-color, --link-hover-color, underline on hover): minimal chrome that reads like an inline link, including inherited font weight.
Markup
<button type="button" class="outline">Cancel</button>
<button type="button" class="text">Learn more</button>
Sizes
Optional .size-xxs through .size-xxl step type and padding together. Omit the size class for the default (primary) scale.
Markup
<button type="button" class="size-s">Compact</button>
<button type="button">Default</button>
<button type="button" class="size-l">Large</button>
Palette fills
Add a swatch class (.red, .blue, .yellow, …) on the same element. Yellow and beige keep dark label copy from the global palette rules; other swatches assume light text.
Markup
<button type="button" class="red">Delete</button>
<button type="button" class="green">Confirm</button>
Icon-only
.icon-button is a square control: 44px by default, 36px with .size-s, 60px with .size-l. Always set aria-label (or visible text) because the target is icon-only.
Markup
<button type="button" class="icon-button round-xl" aria-label="Settings">
<svg>...</svg>
</button>
Disabled
Use the disabled attribute or .disabled for non-interactive presentation. Prefer disabling the real control instead of only dimming with CSS.
Markup
<button type="button" disabled>Unavailable</button>
When to use
- Primary and secondary actions in forms, dialogs, and page headers.
- Pill or toolbar rows where
.size-s/.icon-buttonkeep density without swapping to a different component system. - Destructive or semantic colour when paired with copy and layout that explain the action, not colour alone.
Implementation notes
- Default
<a>links usea:hover:not(.button)for link colour and underline, so<a class="button">is excluded and only gets button hover: an inset fill usingvar(--background-color-fade)(no link colour).nav .wckd-menu/.wckd-menulinks are further overridden to body colour with no underline. - Selectors are paired as
.buttonandbuttoninwckd-ui.cssso behaviour matches; native<button>does not need the.buttonclass, use that class on<a>,<span role="button">, or similar when a real button element is not appropriate. - Default filled controls use neutral tokens (
--button-bgfrom--background-color-light, text from--text-color); use palette swatch classes (.red,.blue, …) when you need semantic colour. Brand tinting is via--primary-colorelsewhere, not the default button fill. - Sizing: default
.button/buttonusemin-height: 2.75rem(44px) andfont-size: inherit;.size-*classes set steppedmin-heightand font size. Icon-only: search for.icon-button(44px default; 36px / 60px with.size-s/.size-l). - Buttons define
:focusand:focus-visiblewithoutline/outline-offsetfor a visible keyboard ring. .outline/.texthave extra rules so the inset hover/active overlays do not fight their transparent style..textmatches global link colour, hover colour, and underline, withfont-weight: inheritandinline-flex/gaplikea.
Developer checklist
- Load
wckd-ui.css(buttons are not inwckd-ui-components.css). No script is required for default hover, active, and focus-visible styles. - Do not add
.buttonto<button>, it is redundant. Add.button(plus modifiers) on<a href="…">or other hosts that should look like a button. - Pair icon-only controls with
aria-labelor screen-reader text; keep hit areas at least 44px for primary actions unless you intentionally use.size-s. - For forms, use
<button type="submit">for the primary action andtype="button"for everything else to avoid accidental submits.