Option
The Option component provides a reusable pattern for option in the interface.
Checkbox
A basic checkbox option with a label, name, and value — the default option type.
Radio buttons
Radio buttons sharing the same name attribute form a group where only one option can be selected at a time.
Pre-checked state
Setting the checked parameter to true renders the option pre-selected on load, for both checkbox and radio types.
Required
Setting required to true adds HTML5 validation attributes so the field must be interacted with before the form can be submitted.
Disabled
Adding the is-disabled class via classList together with the disabled HTML attribute visually disables the option and prevents interaction.
Invalid state
Adding the is-invalid class via classList applies danger-color styling to the box border and label text to signal a validation error.
Valid state
Adding the is-valid class via classList applies success-color styling to the box border and label text to confirm a correct selection.
Small size
Adding the c-option--sm modifier class via classList renders a smaller checkbox box and label font size.
Custom name
The name parameter sets the HTML name attribute on the input; when omitted, the name is derived automatically from the label text.
Value
The value parameter sets the data submitted with the form when the option is checked, allowing multiple checkboxes to share a name while returning distinct values.
Card appearance
Adding c-option--card via classList renders the option as a clickable card with border, hover, checked and focus states. Put c-option__description and c-option__aside (with --success, --danger or --warning) in the label HTML for a secondary line and a tag. The tag sits to the right of the text and moves below it when the card is narrower than 32.5em (container query). Wrap label text containing other markup in one element when using an aside.
Card appearance with checkboxes
The card appearance works for checkboxes too, with or without description and aside.
API
| Parameter | Default | Type | Description |
|---|---|---|---|
|
type
|
checkbox | string | - |
|
label
|
string | - | |
|
required
|
false | boolean | - |
|
value
|
string | - | |
|
checked
|
false | boolean | - |
|
name
|
null | ?string | - |
CSS API
| Variable | Default | Type | Values | Description |
|---|---|---|---|---|
|
--c-option--base
|
var(--base) | range | - | Main unit that drives radius and spacing scales. |
|
--c-option--border-radius
|
var(--border-radius) | range | - | Border Radius |
|
--c-option--color--primary
|
var(--color--primary) | color | - | Primary |
|
--c-option--color--surface
|
var(--color--surface) | color | - | Surface |
|
--c-option--color--danger
|
var(--color--danger) | color | - | Danger |
|
--c-option--color--success
|
var(--color--success) | color | - | Success |
|
--c-option--font-size-100
|
var(--font-size-100) | range | - | Base font size. |
|
--c-option--color--surface-contrast
|
var(--color--surface-contrast) | color | - | Used for text and icons on surface backgrounds with less contrast. |
|
--c-option--color--danger-contrast
|
var(--color--danger-contrast) | color | - | Danger Contrast |
|
--c-option--space
|
var(--space) | range | - | Base spacing unit. Used for padding and margin inside components. |
|
--c-option--border-width
|
var(--border-width) | range | - | Size |
|
--c-option--corner-shape
|
var(--corner-shape) | select | square, round, squircle, circular, bevel, scoop | Corner Shape |
|
--c-option--duration-160
|
var(--duration-160) | range | - | For compact controls and icon changes. |
|
--c-option--ease-out
|
var(--ease-out) | select | - | Default deceleration curve for entering and settling interface elements. |
|
--c-option--color--surface-alt
|
var(--color--surface-alt) | color | - | Manual companion token for subtle surface backgrounds. |
|
--c-option--color--surface-border
|
var(--color--surface-border) | color | - | Manual companion token for borders on surface elements. |
|
--c-option--color--surface-contrast-muted
|
var(--color--surface-contrast-muted) | color | - | Derived muted contrast for text and icons on surface backgrounds. |
|
--c-option--color--focus
|
var(--color--focus) | color | - | Focus |
|
--c-option--color--success-contrast
|
var(--color--success-contrast) | color | - | Success Contrast |
|
--c-option--color--warning
|
var(--color--warning) | color | - | Warning |
|
--c-option--color--warning-contrast
|
var(--color--warning-contrast) | color | - | Warning Contrast |
|
--c-option--font-size-80
|
var(--font-size-80) | range | - | Two steps below base in the type scale. |
|
--c-option--font-size-90
|
var(--font-size-90) | range | - | One step below base in the type scale. |
|
--c-option--font-weight-normal
|
var(--font-weight-normal) | select | 100, 200, 300, 400, 500, 600, 700, 800, 900 | Normal Weight |
|
--c-option--font-weight-bold
|
var(--font-weight-bold) | select | 100, 200, 300, 400, 500, 600, 700, 800, 900 | Bold Weight |
|
--c-option--line-height-heading
|
var(--line-height-heading) | range | - | Heading Line Height |