Buttons
button and .btn get primary background, automatic contrast text and hover/active states derived in oklch from the same color.
Plain <button> and .btn are styled without any class: primary background, automatic contrast text, and hover/active states derived in oklch from the same base color. Links take the primary color too, and input buttons (submit, reset, button) are covered as well.
Hover (×0.8) and active (×0.7) states derive from the base color in oklch, and contrast-color() picks readable text for free, so one color drives the whole button. Focus rings only appear for keyboard users (:focus-visible).
At runtime: --forma-button-font-size, -line-height, -font-weight, -padding and -gap per element, plus --forma-button-color to retint a single button (exactly what .btn-secondary and .btn-contrast do internally). At build time: $font-family-buttons, $border-radius-button and the $color-* palette.
Variants
The plain <button> is the primary action. .btn-secondary and .btn-contrast retint via --forma-button-color, and the .btn-outline* variants keep the same hues as borders over a transparent background.
<div class="flex-row" style="align-items: center">
<button>Primary</button>
<button class="btn-secondary">Secondary</button>
<button class="btn-contrast">Contrast</button>
<button class="btn-outline">Outline</button>
<button class="btn-outline-secondary">Outline secondary</button>
<button class="btn-outline-contrast">Outline contrast</button>
</div>Universal sizes
The universal classes .sm, .lg and .xl scale buttons in cascade: they multiply --forma-font-size-base, so padding and icons scale along with the text.
<div class="flex-row" style="align-items: center">
<button class="sm">Small</button>
<button>Default</button>
<button class="lg">Large</button>
<button class="xl">Extra large</button>
</div>Buttons with icons
Buttons are flex containers, so inline SVG icons align with the text out of the box; .btn-round switches to a 50% radius with 0.5em padding for icon-only buttons.
<div class="flex-row" style="align-items: center">
<button><svg class="bi" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M8 2v7M5 6.5 8 9.5 11 6.5M3 13.5h10"/></svg>Download</button>
<button class="btn-outline"><svg class="bi" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M13.5 8A5.5 5.5 0 1 1 11.9 4.1M13.5 2.5V5H11"/></svg>Refresh</button>
<button class="btn-round" aria-label="Settings"><svg class="bi" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><circle cx="8" cy="8" r="2.5"/><path d="M8 1.5v2M8 12.5v2M1.5 8h2M12.5 8h2M3.4 3.4l1.4 1.4M11.2 11.2l1.4 1.4M12.6 3.4l-1.4 1.4M4.8 11.2l-1.4 1.4"/></svg></button>
<button class="btn-round btn-secondary sm" aria-label="Add"><svg class="bi" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M8 3v10M3 8h10"/></svg></button>
</div>Button groups
.btn-group lays out related actions as one connected control; .btn-group-vertical stacks them. Any button variant works inside.
<div class="flex-row">
<div class="btn-group">
<button>Day</button>
<button>Week</button>
<button>Month</button>
</div>
<div class="btn-group-vertical">
<button class="btn-outline">Rename</button>
<button class="btn-outline">Duplicate</button>
<button class="btn-outline">Delete</button>
</div>
</div>Button group with dropdown
A <details class="dropdown"> inside the group adds a menu without leaving the button language; submenus nest with .dropright.
<div class="flex-row">
<div class="btn-group">
<button>Save</button>
<details class="dropdown">
<summary class="btn">
More
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708"/></svg>
</summary>
<ul>
<li><a href="#">Rename</a></li>
<li>
<details class="dropdown dropright">
<summary>
Export
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708"/></svg>
</summary>
<ul>
<li><a href="#">HTML</a></li>
<li><a href="#">Markdown</a></li>
<li><hr></li>
<li><a href="#">PDF</a></li>
</ul>
</details>
</li>
<li><a href="#">Delete</a></li>
</ul>
</details>
</div>
</div>Form inputs
Input buttons (submit, reset, button) are styled like any other button, no class needed inside a form.
<form class="flex-row">
<input type="text" name="task" placeholder="Task title">
<input type="submit" value="Add task">
<input type="reset" value="Clear">
</form>