domestic-ui GitHub

Buttons

Button variants and sizes, links styled as buttons, and disabled and loading states.

Where buttons are used Buttons sit at the end of a form in the content area: the primary submit button first, with a secondary button beside it.

Live example

Variants

<div class="cluster">
  <button type="button" data-button="primary">Primary</button>
  <button type="button" data-button="secondary">Secondary</button>
  <button type="button" data-button="quiet">Quiet</button>
  <button type="button" data-button="danger">Delete</button>
</div>

Native default

<form action="#native-title" class="cluster">
  <button type="submit">Publish</button>
  <button type="submit" name="draft" value="1" data-button="secondary">Save draft</button>
  <button type="reset" data-button="quiet">Clear</button>
</form>

Sizes

<div class="cluster">
  <button type="button" data-button="primary small">Small</button>
  <button type="button" data-button="primary">Default</button>
  <button type="button" data-button="primary large">Large</button>
</div>
<div class="cluster">
  <a href="#links-title" data-button="primary">Create account</a>
  <a href="#links-title" data-button="secondary">Read the guide</a>
  <a href="#links-title" data-button="quiet">Skip for now</a>
</div>

Disabled

<div class="cluster">
  <button type="button" data-button="primary" disabled>Delete</button>
  <button type="button" disabled>Archive</button>
</div>

Disabled but focusable

<div class="cluster">
  <button type="button" data-button="primary" aria-disabled="true" aria-describedby="publish-why">Publish</button>
  <p id="publish-why" data-text="small muted">Add a title before publishing.</p>
</div>

Loading

<div class="cluster">
  <button type="button" id="save-demo" data-button="primary">Save changes</button>
  <p id="save-status" role="status" data-text="small muted"></p>
</div>

Attributes

data-button="[primary | secondary | quiet] [small | large] [icon]" on <button>, <input type=submit|button|reset>, <a href>; states disabled, aria-disabled="true", aria-busy="true"

Attribute or valueWhereEffect
data-button="[primary | secondary | quiet | danger] [small | large] [icon]"<button>, <input type="submit | button | reset"> or <a href>at most one variant word, one size word and icon
  • On <a href>, it looks like a button and keeps link semantics.
  • Our choice: data-button with no variant word keeps the native default (a submit button is primary, everything else is secondary), so M1 markup keeps working and the attribute is only needed when the native type does not match the emphasis you want.
  • Our choice: the secondary button sits on the page surface with a softer border (--dui-color-border-button, neutral step 7) and a 1px shadow. Its visible text label identifies it, so WCAG 1.4.11 does not require a 3:1 boundary; fields, selects, checkboxes, radios and switches keep the 3:1 --dui-color-border-control.
  • Our choice: the quiet button uses the accent color for its text, so it still reads as interactive without a border, and its hover and pressed fills are neutral steps 4 and 5. Use it next to other buttons, not inside running text, where a real link belongs.
  • Our choice: buttons, fields, selects and badges use the 14px interface size (--dui-font-size-ui). Fields, selects and text areas use --dui-font-size-field, which is at least 16px under a coarse pointer, because iOS Safari zooms into a focused field with smaller text.
  • Our choice: primary buttons add an inner focus ring in their text color on top of the shared outline, so the indicator contrasts with the fill as well as the surface. This is the double-ring technique described in WCAG technique C40.
  • Our choice: default buttons and fields are 36px tall and large ones 40px, and a coarse (touch) pointer restores 44px, between Primer and Radix (32px) and Material (40px), for comparison.
  • Our choice: small buttons are 32px tall: below the 36px default, above the 24px minimum.
  • Our choice: aria-disabled="true" looks exactly like disabled. Prefer native disabled; use aria-disabled when users should be able to reach the control and read why it is unavailable.
  • Our choice: an icon-only button (data-button="icon") is named by visually hidden text inside it, not aria-label, because real text is translated by browser translation tools and copied with the page. Its <dui-tooltip> shows the same words and is aria-hidden, so the name is announced once; with JavaScript off the button keeps its name.

States

Attribute or valueEffect
disabledNative. Removed from the tab order, not submitted.
aria-disabled="true"Looks disabled and is exposed as disabled, but stays focusable so a description can explain why. Your script must ignore activation.
aria-busy="true"Work in progress. Change the visible label too ("Saving…") and announce the result in a role="status" region; nothing here hides the label.

Sizes

Default is 36px and large 40px tall, both 44px or more under a coarse pointer. small is 32px, above the 24px minimum of WCAG 2.5.8 Target Size (Minimum). The default size follows density (--dui-size-control): 32px inside data-density="compact". small and large keep their size at every density.

Focus

Every variant keeps the base :focus-visible ring, which hugs the edge. Filled (primary) buttons add a 1px inner line in their text color, so the indicator contrasts with the fill as well as with the surface, whatever the theme (WCAG 1.4.11, 2.4.13).

Motion

Background and border colors fade over --dui-motion-duration-fast with --dui-motion-easing-standard. A pressed (:active) button scales to --dui-motion-press-scale (0.98), which is 1 under reduced motion (WCAG 2.3.3). Focus rings, disabled and aria-busy change at once: they are essential feedback.

Accessibility

  • aria-disabled="true" stays focusable, so a description can say why. Your script must ignore activation (APG).
  • With aria-busy="true", also change the label ("Saving…") and announce the result in a role="status" region.

Specifications

See also

How other systems do it

For comparison only; these are not the standard this system follows.

Search