Select
<forma-select>
An ordinary native select with platform picker behavior and physics-derived CSS affordance motion.
- Authoring tag
<forma-select>- Category
- Form inputs
- Behavior owner
- Native HTML
- Canonical source
patterns/select.html
Purpose
A select picks one value from a fixed list. Forma wraps a native select so the browser remains the authority for the value, options, keyboard, type-ahead, picker, validity and form submission. .forma-select-field is the labelled field (a label element containing label text, control and description); .forma-select draws a chevron indicator that rotates while the picker is open in browsers that support the :open pseudo-class.
Use when
- The user chooses exactly one value from a known list of roughly five or more options.
- The list is stable and the options are short text.
- Screen space is limited and seeing all options at once is not important.
Avoid when
- There are two to five options and comparing them matters: use Choice group or Segmented control so all options are visible.
- The list is long enough that users need to type to filter, or values may be new: use Combobox.
- Several values may be chosen: use Multi-choice or a set of Checkbox controls;
multipleis not styled by.forma-select. - Options need secondary text, icons or grouping beyond
optgroup: this needs an application-owned custom listbox.
Behavior to know
- Native
selectwithappearance: none, a 44px minimum height and room at the inline end for the indicator. - The indicator is decorative (
aria-hidden) and never intercepts pointer input. - The open-state rotation is progressive enhancement; the control works fully without it.
Basic example
The smallest correct markup: the canonical pattern from patterns/select.html inside its public tag. Copy this first, then adapt labels, names and state.
Minimal select
Rendered from the canonical pattern file.
<forma-select class="forma-component-tag">
<label class="forma-select-field">
<span class="forma-field__label">Deployment region</span>
<span class="forma-select" data-forma-motion-weight="standard">
<select class="forma-select__input" name="region" aria-describedby="region-description">
<option value="us-east">US East</option>
<option value="us-west">US West</option>
<option value="eu-west">Europe West</option>
</select>
<span class="forma-select__indicator" aria-hidden="true"></span>
</span>
<span class="forma-field__description" id="region-description">Choose where this workload will run.</span>
</label>
</forma-select>
Click or tap the code once to select all of it, then copy.
Examples
Required choice with grouped options
Time zones grouped with optgroup. An empty first option makes the unselected state explicit so the native required constraint can catch a missing choice.
<forma-select class="forma-component-tag">
<label class="forma-select-field">
<span class="forma-field__label">Reporting time zone (required)</span>
<span class="forma-select" data-forma-motion-weight="standard">
<select class="forma-select__input" name="report-timezone" required aria-describedby="select-grouped-timezone-description">
<option value="">Choose a time zone</option>
<optgroup label="Americas">
<option value="America/New_York">New York (UTC−05:00)</option>
<option value="America/Los_Angeles">Los Angeles (UTC−08:00)</option>
</optgroup>
<optgroup label="Europe">
<option value="Europe/London">London (UTC+00:00)</option>
<option value="Europe/Berlin">Berlin (UTC+01:00)</option>
</optgroup>
</select>
<span class="forma-select__indicator" aria-hidden="true"></span>
</span>
<span class="forma-field__description" id="select-grouped-timezone-description">Daily reports close at midnight in this time zone.</span>
</label>
</forma-select>
Click or tap the code once to select all of it, then copy.
Locked by plan
A retention period the current plan does not allow changing. The select is natively disabled and dimmed; the description explains why.
<forma-select class="forma-component-tag">
<label class="forma-select-field">
<span class="forma-field__label">Log retention</span>
<span class="forma-select">
<select class="forma-select__input" name="log-retention" disabled aria-describedby="select-locked-retention-description">
<option value="30" selected>30 days</option>
<option value="90">90 days</option>
<option value="365">1 year</option>
</select>
<span class="forma-select__indicator" aria-hidden="true"></span>
</span>
<span class="forma-field__description" id="select-locked-retention-description">Longer retention is available on the Business plan.</span>
</label>
</forma-select>
Click or tap the code once to select all of it, then copy.
Heavy indicator weight with long option text
A heavy presentation weight gives the indicator a slower, more settled rotation. Long option labels are truncated by the platform in the closed control but shown in full in the picker.
<forma-select class="forma-component-tag">
<label class="forma-select-field">
<span class="forma-field__label">Escalation policy</span>
<span class="forma-select" data-forma-motion-weight="heavy">
<select class="forma-select__input" name="escalation-policy">
<option value="primary">Page the primary on-call engineer, then the secondary after 10 minutes</option>
<option value="team">Notify the whole platform team channel immediately</option>
<option value="manager">Page the primary on-call engineer and the duty manager at the same time</option>
</select>
<span class="forma-select__indicator" aria-hidden="true"></span>
</span>
</label>
</forma-select>
Click or tap the code once to select all of it, then copy.
Mobile
Each mobile example renders in its own document inside a real narrow viewport, so Forma's media and container queries run exactly as they would on a phone. Choose a width to compare.
Mobile country picker
A country select at phone width. The control fills the width and the platform picker takes over on tap.
What changes at narrow widths
- The select fills the available width and keeps a 44px minimum height; the indicator stays pinned 1rem from the inline end.
- Tapping opens the operating system's picker (a wheel or bottom sheet on most phones), which Forma does not style.
- The closed control truncates a long selected option on one line; the description wraps below it.
- Orientation changes only change the width. Long option labels stay within the available width even at 200% text size.
<forma-select class="forma-component-tag">
<label class="forma-select-field">
<span class="forma-field__label">Country or region</span>
<span class="forma-select">
<select class="forma-select__input" name="country" autocomplete="country" aria-describedby="select-mobile-country-description">
<option value="GB">United Kingdom</option>
<option value="IE">Ireland</option>
<option value="US">United States</option>
<option value="AE">United Arab Emirates</option>
</select>
<span class="forma-select__indicator" aria-hidden="true"></span>
</span>
<span class="forma-field__description" id="select-mobile-country-description">Used for tax calculation on invoices.</span>
</label>
</forma-select>
Click or tap the code once to select all of it, then copy.
Mobile · 320px
The canonical pattern in a true 320px viewport, the minimum width every Forma component must support without page-level horizontal scrolling.
API and configuration
Forma components have no JavaScript API. Their public contract is the markup: native elements and attributes you write, and the CSS hooks below. The CSS hook table is generated from the built stylesheet, so it always matches the shipped implementation.
| Attribute | On | Values | Default | Description |
|---|---|---|---|---|
name | select | string | — | Form field name used on submission. |
required | select | boolean | absent | With an empty-value first option, blocks submission until a real option is chosen. |
disabled | select | boolean | absent | Removes the select from focus and submission and dims the control. |
selected | option | boolean | first option | Initial selection. |
label | optgroup | string | — | Visible, announced group heading for a set of options. |
autocomplete | select | country | … | browser heuristic | Lets the browser autofill a known value. |
aria-describedby | select | id of the description | — | Links the .forma-field__description guidance. |
aria-hidden | .forma-select__indicator | true | — | Required on the indicator so the decorative chevron is not announced. |
| Hook | Kind | Values or default | Description |
|---|---|---|---|
.forma-select | Block class | — | Positioning wrapper for the native select and the indicator. Carries the motion scope. |
.forma-select__indicator | Element class | — | Decorative chevron drawn with borders. Rotates when the select is :open. |
.forma-select__input | Element class | — | The native select: full width with shrinkable intrinsic sizing for narrow containers and enlarged text, 44px minimum height, appearance: none, inline-end padding for the indicator, dimmed with a not-allowed cursor when disabled. |
[data-forma-motion-weight] | Attribute hook | "heavy", "light", "standard" | Presentation-only perceived mass for the indicator rotation: light, standard (default) or heavy. Gravity-derived vertical travel is independent of mass. |
.forma-select-field | Block class | — | Root label grid holding label text, the select wrapper and the description with a 0.5rem gap. Wrapping makes the label text name the select. |
| Keys | Result |
|---|---|
| Tab / Shift+Tab | Moves focus to and from the select. |
| ArrowUp / ArrowDown | Changes the selection or moves within the open picker (platform-dependent). |
| Alt+ArrowDown / Space / Enter | Opens the picker; exact keys vary by platform. |
| Printable characters | Type-ahead jumps to the first matching option. |
| Escape | Closes an open picker without changing the value. |
| Event | Description |
|---|---|
input / change | Native events when the selection changes. Forma adds none. |
Form behavior
A native select: submits the selected option's value under name, supports required, restores the initially selected option on reset and is excluded when disabled.
States
| State | How it is expressed | Presentation |
|---|---|---|
| Closed | default | Chevron points down. |
| Open | :open on the select (progressive enhancement) | Chevron rotates to point up and shifts slightly. Browsers without :open keep the closed indicator; the picker still works. |
| Focus | :focus-visible | Foundation two-tone focus ring around the select. |
| Disabled | disabled attribute | Select at reduced opacity with a not-allowed cursor. |
| Invalid | native :invalid with required and an empty value | Not restyled by Forma; show a Validation message after a failed submit. |
Accessibility
Forma provides
- Keeps the native select, so role, value, options, type-ahead and picker are provided by the platform and assistive technology.
- The label element wraps the control, naming it and enlarging the click target.
- The indicator is decorative and pointer-transparent; the control keeps a 44px minimum height and the shared focus ring.
- Borders map to CanvasText in forced-colors mode.
Your application supplies
- Give the select a visible label and mark aria-hidden="true" on the indicator.
- Use an explicit empty first option for required selects rather than preselecting a guess.
- Explain a disabled select in its description and show errors with a linked Validation message.
Responsive behavior
- The field and control fill their container (
inline-size: 100%,max-inline-size: 100%). - Long option text is truncated by the platform in the closed control; the picker shows full text.
- No breakpoints; on touch devices the operating system supplies its own picker.
Motion
- When the picker opens, the chevron rotates 180 degrees with the shared inertial spring and drops slightly with gravity-derived timing; it reverses on close.
data-forma-motion-weightchanges the rotation's perceived mass only; vertical gravity timing does not depend on mass.- The select's background and border use perceptual interpolation when they change.
- The value changes immediately; the indicator motion never gates the picker.
- Under
prefers-reduced-motion: reducedurations become effectively zero and the vertical shift is removed; the rotation still shows the open state.
Motion weights
Forma motion is physics-derived: perceived mass changes how a surface accelerates and settles, never what state it is in. Compare the three presentation weights of the same markup:
Usage guidance
Do
- Order options logically (alphabetical, numerical or by frequency) and keep labels short.
- Prefer visible radio options for short lists where comparison helps.
Avoid
- Using a select for navigation or to trigger actions on change.
- Replacing the native select with a custom listbox only for styling.
Verification specimens
Generated fault-injection specimens expose content, spacing, color-cue, and reduced-effective-contrast risks. They screen presentation robustness as engineering screens without claiming human-subject validation.