Selection card
Card-shaped choices with visible native radios or checkboxes, descriptions and optional prices.
When to use
Use a selection card when choosing a plan, delivery method or appointment format needs more context than a short label. Use native radios for one value and checkboxes for independent choices. Use an action Card for navigation or commands, or a Segmented control for short, compact single-value choices.
Class reference
| Class | Purpose |
|---|---|
.selection-card |
Label wrapping one native input and its content; the whole surface selects it. |
.selection-card-input |
Visible native radio or checkbox, directly inside the label. |
.selection-card-content |
Flexible content column for title, description and optional price or icon. |
.selection-card-description |
Block description using the component’s secondary text color. |
Single selection
Group radios in a fieldset with a legend, shared name and distinct value attributes. The native checked property controls the selected surface; no active class or JavaScript is needed. Hover keeps the selected appearance. The booking example uses the same component.
<fieldset class="border border-0 min-w-0 p-0 m-0">
<legend class="form-label">Appointment format</legend>
<div class="d-flex flex-column gap-2">
<label class="selection-card">
<input
class="selection-card-input"
type="radio"
name="format"
value="video"
checked
required />
<span class="selection-card-content">
<strong>Video consultation</strong>
<span class="selection-card-description"
>Join from a private link sent by email.</span
>
</span>
</label>
<label class="selection-card">
<input
class="selection-card-input"
type="radio"
name="format"
value="office"
required />
<span class="selection-card-content">
<strong>In person</strong>
<span class="selection-card-description">Visit our office in Berlin.</span>
</span>
</label>
<label class="selection-card">
<input class="selection-card-input" type="radio" name="format" value="phone" disabled />
<span class="selection-card-content">
<strong>Phone consultation</strong>
<span class="selection-card-description">Currently unavailable</span>
</span>
</label>
</div>
</fieldset>Multiple selection
Checkboxes remain independent. Use the same name for repeated values and read all checked values from the submitted form. Native required applies to an individual checkbox; requiring at least one checked item from a group needs application validation.
<fieldset class="border border-0 min-w-0 p-0 m-0">
<legend class="form-label">Consultation extras</legend>
<div class="d-flex flex-column gap-2">
<label class="selection-card">
<input
class="selection-card-input"
type="checkbox"
name="extras"
value="summary"
checked />
<span class="selection-card-content">
<strong>Written summary</strong>
<span class="selection-card-description">The main results by email. Included.</span>
</span>
</label>
<label class="selection-card">
<input class="selection-card-input" type="checkbox" name="extras" value="follow-up" />
<span class="selection-card-content">
<strong>Follow-up call</strong>
<span class="selection-card-description"
>15 minutes for open questions. + €20.</span
>
</span>
</label>
</div>
</fieldset>Responsive plans, prices and icons
Use existing Grid utilities for stacked choices that become columns from the medium breakpoint. Stretch the labels with .h-100 for equal card heights. Content wraps at narrow widths and follows dir="rtl"; no special orientation modifier is needed. Keep icons decorative alongside visible text, and include the currency and billing interval in the price.
<fieldset class="border border-0 min-w-0 p-0 m-0">
<legend class="form-label">Project plan</legend>
<div class="grid gap-2">
<div class="col-12 col-md-6">
<label class="selection-card h-100">
<input class="selection-card-input" type="radio" name="plan" value="basic" />
<span class="selection-card-content">
<strong>Basic</strong>
<span class="selection-card-description">1 member · 5 projects</span>
<span class="d-block mt-3 h4 mb-0"
>€9 <span class="text-sm">/ month</span></span
>
</span>
</label>
</div>
<div class="col-12 col-md-6">
<label class="selection-card h-100">
<input class="selection-card-input" type="radio" name="plan" value="team" checked />
<span class="selection-card-content">
<span class="d-flex align-items-center gap-1">
<span class="icon icon-sm" aria-hidden="true"
><!-- Decorative shield SVG --></span
>
<strong>Team</strong>
</span>
<span class="selection-card-description">10 members · Unlimited projects</span>
<span class="d-block mt-3 h4 mb-0"
>€29 <span class="text-sm">/ month</span></span
>
</span>
</label>
</div>
</div>
</fieldset>Invalid and disabled states
Put .is-invalid and aria-invalid="true" on the input and connect a visible error using aria-describedby. An input marked with either invalid marker gives its card an error border. Inside .was-validated, native :invalid also styles the card. These styles perform no validation and do not announce messages on their own. Clear application-owned invalid markers and feedback when the error is resolved.
Disable one input with disabled or the whole group with a disabled fieldset. Disabled styles take precedence over hover, checked and invalid surfaces; the visible native control still communicates its checked state.
Please confirm permission before sharing.
<label class="selection-card">
<input
class="selection-card-input is-invalid"
type="checkbox"
name="consent"
aria-invalid="true"
aria-describedby="consentError"
required />
<span class="selection-card-content">
<strong>Share my consultation notes</strong>
<span class="selection-card-description">Confirm permission to share with your team.</span>
</span>
</label>
<p class="text-error text-sm mt-1 mb-0" id="consentError">
Please confirm permission before sharing.
</p>Accessibility and keyboard behavior
- Keep one visible native radio or checkbox directly inside each wrapping label. Put only phrasing content such as
strongandspaninside it, with no nested links, buttons or other controls. Afieldsetandlegendname the group; the card text names its input. - Tab enters a radio group; arrow keys move focus and selection between enabled choices. Space selects the focused radio. For checkboxes, Tab visits each enabled input and Space toggles it. Keep native keyboard behavior; the card gets an additional visible keyboard-focus outline.
- Only checked, enabled inputs contribute their
nameandvalueto form submission. Native form reset restores the initialcheckedattributes. UseFormData.getAll(name)for repeated checkbox values. Nativerequiredcan require a radio-group value or one specific checkbox. - Selection remains visible through the native checked control, including forced colors and disabled groups; meaning does not depend on the tinted background. Explain unavailable choices in text. Card styling has no animation and needs no reduced-motion override.
- No runtime JavaScript or initialization is required, including after Astro navigation. Applications own validation messages and any summaries that react to native
changeevents. Do not use tab roles,aria-pressedor a separate visual active state.
CSS variables
Override these base defaults on the listed selector after the library styles. Variants and states may replace them; global tokens follow the active theme.
| Token | Default | Purpose | Scope / state |
|---|---|---|---|
--selection-card-padding | var(--spacer-3) | Space inside a choice. | .selection-card |
--selection-card-gap | var(--spacer-2) | Space between input and content. | .selection-card |
--selection-card-bg-color | var(--bg-surface) | Default background. | .selection-card |
--selection-card-border-width | var(--border-width) | Border and checked inset thickness. | .selection-card |
--selection-card-border-color | var(--control-border-color) | Default border. | .selection-card |
--selection-card-border-radius | var(--border-radius) | Corner radius. | .selection-card |
--selection-card-hover-bg-color | var(--bg-surface-hover) | Unselected hover background. | .selection-card |
--selection-card-checked-bg-color | color-mix(in srgb, var(--primary) 8%, var(--bg-surface)) | Selected background, also on hover. | .selection-card |
--selection-card-checked-border-color | var(--primary) | Selected border and inset. | .selection-card |
--selection-card-description-color | var(--text-muted) | Description color; disabled choices inherit disabled text. | .selection-card |
--selection-card-input-size | 1.125rem | Native radio or checkbox size. | .selection-card |
For selective imports, load @use '@oardi/css-utils/tokens'; followed by @use '@oardi/css-utils/components/selection-card';. Inputs keep their native browser appearance; no Form or Card stylesheet is required. Layout and text utilities used by the examples need their corresponding imports or the full library. Focus, error and disabled states use the shared focus, error and disabled tokens.