<link rel="stylesheet" href="https://esm.sh/@erikt/ui/radio.css" />Default
<input type="radio" name="group" /> <input type="radio" name="group" checked />
With label
<label>
<input type="radio" name="density" value="default" />
Default
</label>
<label>
<input type="radio" name="density" value="comfortable" checked />
Comfortable
</label>
<label>
<input type="radio" name="density" value="compact" />
Compact
</label>
Disabled
<label>
<input type="radio" name="density" disabled />
Default
</label>
<label>
<input type="radio" name="density" disabled checked />
Comfortable
</label>
Choice card
A card-style radio group. Semantic markup plus a few lines of CSS.
<style>
.choice-card .card {
display: flex;
justify-content: space-between;
align-items: flex-start;
}
.choice-card .card:has(input:checked) {
background: var(--ui-neutral-100);
border-color: var(--ui-neutral-600);
}
</style>
<fieldset>
<label class="choice-card">
<article class="card">
<small>
<hgroup>
<h3>Plus</h3>
<p>For individuals and small teams.</p>
</hgroup>
</small>
<input type="radio" name="plan" value="plus" />
</article>
</label>
<label class="choice-card">
<article class="card">
<small>
<hgroup>
<h3>Pro</h3>
<p>For growing businesses.</p>
</hgroup>
</small>
<input type="radio" name="plan" value="pro" checked />
</article>
</label>
</fieldset>
API reference
| Type | Classes / attributes | What it does |
|---|---|---|
| Disabled | [disabled] |
Fades the radio and its label and blocks input |