Usage
Every component follows the same four rules. Learn them once and the rest is a class list.
1. One class makes the component
btn, card, badge, modal. Put it on the natural HTML element: a button, an article, a dialog.
<article class="card">
<p class="card-title">Night walk</p>
<p>Shibuya after the rain.</p>
</article>2. Modifiers change shape and size
They are named after the component: btn-outline, btn-sm, avatar-lg, toast-top.
<button class="btn btn-outline btn-sm">Small outline</button>3. A suffix sets the colour
Add -primary, -secondary, -success, -warning or -danger to any component that has a colour. It works the same everywhere.
<button class="btn btn-primary">Save</button>
<span class="badge badge-success">Live</span>
<div class="alert alert-danger" role="alert">Payment failed.</div>
<progress class="progress progress-secondary" value="70" max="100"></progress>4. State comes from HTML, not classes
Use the attributes the platform already has: disabled, open, aria-busy, aria-invalid, aria-selected, aria-current. Your markup stays accessible and there is nothing to keep in sync. Where HTML has no attribute for a state, Glimmer uses a data attribute: data-done on a finished step or timeline entry.
<button class="btn btn-primary" aria-busy="true">Saving</button>
<input class="input" aria-invalid="true" value="not-an-email">
<button class="tab" role="tab" aria-selected="true">Overview</button>With Tailwind
Glimmer sits in Tailwind's components layer, so a utility on the same element always wins. Use utilities for layout and for one-off tweaks.
<button class="btn btn-primary rounded-full px-8 md:h-12">Wider and rounder</button>To put Tailwind variants on Glimmer's own modifiers, such as md:btn-lg or hover:btn-primary, add one more import. It covers sizes, colours and frost levels.
@import "tailwindcss";
@import "glimmer-ui";
@import "glimmer-ui/css/tailwind.css";Overlays use the browser
Modal and drawer are native dialogs, and popover is the native popover attribute. Opening, closing, focus handling and Esc are the browser's job, so none of them need a script from the kit.
The few things that need a script
Load behaviors.js once and these work from markup alone, including markup added later: tabs that switch panels and answer to the arrow keys, toasts from a function call, carousel buttons, a search field that filters a list, and tooltips that screen readers can read.
import { toast } from "glimmer-ui/behaviors.js";
toast("Saved.", { type: "success" });Reading direction, print and contrast
Components follow the page's direction, so dir="rtl" mirrors them. Pages print in the light theme without glows or shadows. People who ask their system for more contrast or less transparency get more solid panels, and Windows high-contrast mode keeps every state visible.
Motion
Glimmer's animations play once and stop for people who have asked their system to reduce motion. Your own animations are left alone.