Design System

Button reference ​

Every prop, value and rendered attribute. For what the component is for, see Overview. For how to write one, see Usage. Measurements are given at the default interface text size of 14.

Props ​

PropTypeRequiredDefaultMeaning
labelstringYesnoneThe visible text, and the accessible name when iconOnly is set
iconstringNononeA FontAwesome class string rendered before the label. Replaced by the spinner while loading
trailingIconstringNononeA FontAwesome class string rendered after the label. Left in place while loading
iconOnlybooleanNofalseDrops the label text from the DOM and moves it to aria-label
severityCButtonSeverityNo"contrast"Selects the fill, border and foreground tokens
variantCButtonVariantNo"solid"Selects the emphasis treatment
sizeCButtonSizeNo"medium"Selects the label type role and the padding
fluidbooleanNofalseSets the width to 100 per cent of the parent content box
loadingbooleanNofalseSwaps the leading icon for a spinner and disables the button
disabledbooleanNofalseSets the native disabled attribute and the disabled treatment
type"button" | "submit" | "reset"No"button"The native button type

Events ​

The component declares no emits. Listeners arrive through the forwarded attributes and land on the native button, so the payload is the native event.

ListenerPayloadNotes
@clickMouseEventAttached at 328 of the 371 call sites
@click.stopMouseEventModifiers survive forwarding, which a test pins
Any on[A-Z] listenerThe native event@mousedown, @focus and the rest forward the same way

Slots ​

The component renders no slot. Its children are fixed at an optional leading icon, an optional label span and an optional trailing icon, in that order, so a badge, a count pill or a shortcut chip cannot be placed inside a button.

Severities ​

Seven values. CButtonSeverity is the shared Severity union plus "primary", which this component adds.

SeveritySolid fill and borderSolid foregroundOutlined and text foregroundOutlined border
primary--color-fill-primary--color-fg-on-primary--color-fg-primary--color-fill-primary
contrast--color-fill-neutral-subtle--color-fg-on-neutral-subtle--color-fg-muted--color-line-default
secondary--color-fill-secondary--color-fg-on-secondary--color-fg-secondary--color-line-secondary
success--color-fill-success-strong--color-fg-on-success--color-fg-success--color-fill-success
info--color-fill-info-strong--color-fg-on-info--color-fg-info--color-fill-info
warn--color-fill-warn-strong--color-fg-on-warn--color-fg-warn--color-line-warn
danger--color-fill-danger-strong--color-fg-on-danger--color-fg-danger--color-fill-danger

The fg-on-* foregrounds are built against the fills in the second column, four of which carry the -strong step. Colour holds the measured pairings.

Variants ​

VariantBackgroundBorderHover
solidThe severity fill1 pixel, the colour of the fillFill and border move to their -hover step
outlinedTransparent1 pixel, the border token aboveA background tint appears; the border does not change
textTransparentNone. The border colour is transparent and carries no widthThe same background tint as outlined

Geometry ​

SizeLabel sizeLabel line boxPaddingGap
small1214.56 top and bottom, 12 each side8
medium14178 top and bottom, 12 each side8
large182212 top and bottom, 16 each side8

Heights, in pixels:

smallmediumlarge
Labelled, solid or outlined28.53548
Labelled, text26.53346
Icon-only, solid or outlined263244
Icon-only, text243042

An icon-only button is shorter because an icon box has a line height of 1 while a label box has a line height of normal. A text button carries no border width, so it is also 2 pixels narrower. The label weight is 400 at all three sizes, and the padding does not move with the interface text setting.

Width is the side padding, the border, each child and an 8 pixel gap between children, or 100 per cent of the parent with fluid. The corner is 6 pixels at every size, variant and severity.

States ​

StateWhat changesValue
HoverBackground, and the border on solidTransitioned over 200ms on the standard curve
ActiveA wash over the existing background--color-fg-strong at 20 per cent
FocusAn outline drawn by the interface rather than by the component2 pixels of --color-line-focus, offset 2, on :focus-visible
DisabledOpacity, pointer events, the native attribute--opacity-disabled at 0.6, pointer-events: none
LoadingThe disabled treatment, plus a spinner in place of the leading iconfas fa-spinner animate-spin

The rendered element ​

One native <button>, with up to three children and no wrapper.

html
<button type="button" class="c-button …" data-pc-name="button" data-p-severity="contrast">
  <i class="fas fa-plus" aria-hidden="true"></i>
  <span class="truncate">Save</span>
  <i class="fas fa-caret-down" aria-hidden="true"></i>
</button>

data-p-severity is absent when the severity is primary, which is translated away before it reaches the component library, so a selector written for [data-p-severity="primary"] matches nothing. The stable hooks are the c-button class, [data-pc-name="button"] and the scoped data-v- attribute the pressed wash is drawn on. The pc<n> attribute is a per-instance selector whose number moves with mount order.

ARIA ​

AttributeWhen it is setValue
aria-labeliconOnly is trueThe label prop
aria-hiddenOn each icontrue
disableddisabled or loading is trueThe native attribute, plus data-p-disabled="true"

The component sets no role, aria-disabled, aria-busy, live region, aria-pressed or aria-expanded.

Forwarded attributes ​

The component sets inheritAttrs: false and binds one allow-list, /^(data-|aria-|on[A-Z])|^(id|name|form)$/.

Reaches the button
data-*Yes
aria-*Yes, except aria-label, which is overwritten after forwarding
on[A-Z] listenersYes
id, name, formYes
class, style, title, tabindex, roleNo, dropped without a warning
A pass-through styling objectNo
A class-shaped prop under another nameNo

Three tests pin the refusal of a class, a pass-through styling object and a class-shaped prop under another name.

Directives are a separate mechanism and do apply, which is why v-tooltip is the route to a tooltip and title is not.