Button

Buttons carry the primary color by default. In the classless build every button, [type="button"], [type="submit"], [type="reset"] and [role="button"] gets the same treatment.

ClassDoes what
btnBase button
btn-primaryPrimary color fill (the default look)
btn-secondaryTransparent with a border
btn-ghostNo border, no fill
btn-neutralFills from the fallback color instead of the theme color
btn-disabledGreyscale, for elements without a disabled attribute

Basic

<button class="btn">Button</button>
<a href="#" class="btn">Link button</a>

Variants

<button class="btn btn-primary">Primary</button>
<button class="btn btn-secondary">Secondary</button>
<button class="btn btn-ghost">Ghost</button>
<button class="btn btn-neutral">Contrast</button>

Classless: the modifier classes are bare (<code>.primary</code>, <code>.contrast</code>) because they only apply to elements the theme already styles.

Disabled

<button class="btn" disabled>Disabled</button>
<button class="btn btn-disabled">Looks disabled</button>

Unstyling a button

<div class="prose">
  <p>Read more about <button class="semantic" style="text-decoration: underline">this topic</button>.</p>
</div>

.semantic unsets every style so a button can sit inside a sentence. It works in both builds.

Input buttons

<input type="submit" class="btn" value="Submit" />
<input type="reset" class="btn" value="Reset" />

Button-type inputs are styled as buttons in both builds. In 1.x the classless build also applied the text-field rules to them, so they stretched to the full width and carried a bottom margin.

Composition

Common ways to put this together with other components. The general rules are on Composition.

One primary action per region

A hero with one filled button, and a confirm row where the safe choice is secondary.

Same markup in both builds
<div style="display: grid; gap: var(--padding)">
<section class="prose" style="max-width: 40rem">
  <h1>Software your business actually runs on</h1>
  <p>Intake, scheduling and the site that feeds them, built and looked after by one person.</p>
  <a href="#" class="btn">Book a call</a>
  <a href="#" class="btn btn-ghost">See the work</a>
</section>
<article class="card prose">
  <h3>Cancel this booking?</h3>
  <p>The time goes back on the calendar for someone else.</p>
  <footer class="card-actions flex" style="justify-content: end">
    <button class="btn btn-secondary">Keep it</button>
    <button class="btn">Cancel booking</button>
  </footer>
</article>
</div>

Equal choices

When no option is the main one, none of them is filled.

Same markup in both builds
<div class="prose">
  <h3>Add to your calendar</h3>
</div>
<div class="flex" style="flex-wrap: wrap">
  <a href="#" class="btn btn-secondary">Google</a>
  <a href="#" class="btn btn-secondary">Apple / Outlook</a>
  <a href="#" class="btn btn-ghost">Download .ics</a>
</div>

Busy

While a form submits, its button keeps the label, gains a spinner, and is disabled until the work is done.

Same markup in both builds
<form class="card" style="max-width: 24rem">
  <label class="label"><p>Email</p><input class="input" type="email" value="name@example.com" /></label>
  <button class="btn" disabled aria-busy="true"><span class="loading" style="vertical-align: middle"></span> Sending</button>
</form>

A toolbar

Ghost buttons in groups, split by a vertical divider, with a tooltip naming the one under the pointer.

Same markup in both builds
<div class="flex" style="align-items: center; gap: calc(var(--padding) / 4)">
  <button class="btn btn-ghost">Undo</button>
  <button class="btn btn-ghost">Redo</button>
  <div class="divider divider-vertical" style="height: 1.5rem; margin: 0 calc(var(--padding) / 2)"></div>
  <span style="position: relative; display: inline-block">
    <button class="btn btn-ghost" aria-describedby="ctip">Link</button>
    <span class="tooltip-content" role="tooltip" id="ctip" style="position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 0.25rem; white-space: nowrap">Add a link (Ctrl K)</span>
  </span>
  <button class="btn btn-secondary" style="margin-left: auto">Share</button>
</div>