Dropdown menu for choosing from a list of predefined options. Vanilla Breeze resets the native appearance and adds a currentColor chevron, consistent sizing, and focus styling via design tokens.
When to Use
- Choosing from a predefined list (countries, categories, sizes)
- When the list has more than 5 options (otherwise consider radio buttons)
- When screen space is limited
- When the user cannot enter custom values
Consider alternatives:
- Radio buttons for 2-5 options when space allows
- datalist when users can type custom values alongside suggestions
- combo-box for a fully custom filterable dropdown
Examples
Basic select, optgroup categorization, multiple selection, and disabled states.
Basic Select
<label for="country">Country</label><select id="country" name="country"> <option value="">Select a country...</option> <option value="us">United States</option> <option value="ca">Canada</option> <option value="uk">United Kingdom</option></select>
With Option Groups
Organize options into categories using optgroup.
<select id="product"> <option value="">Select a product...</option> <optgroup label="Electronics"> <option value="laptop">Laptop</option> <option value="phone">Smartphone</option> </optgroup> <optgroup label="Accessories"> <option value="case">Phone Case</option> <option value="charger">Charger</option> </optgroup></select>
Multiple Selection
Allow selecting multiple options with the multiple attribute. Use size to control how many options are visible.
<select multiple size="5"> <option value="html">HTML</option> <option value="css">CSS</option> <option value="js">JavaScript</option> <option value="python">Python</option> <option value="rust">Rust</option></select>
Required, with a Placeholder Option
A required single-row select is only invalid when the selected option is the placeholder label option: the first option, with an empty value="", and not inside an <optgroup>. Without that placeholder the browser selects the first real option and required never fails. The rule does not apply to multiple or size greater than 1: those are invalid only when nothing is selected.
The shared form layer styles select:user-invalid with the error border once the user has interacted, so an untouched form is not painted red on load.
<label for="plan">Plan</label><select id="plan" name="plan" required> <option value="">Choose a plan...</option> <option value="free">Free</option> <option value="pro">Pro</option></select>
Adding disabled to the placeholder (<option value="" disabled selected>) stops users from re-choosing it once they have picked a value. It is still the placeholder, so validation works the same way.
Disabled States
Disable the entire select or individual options within it.
<select disabled> <option>Cannot change</option></select> <select> <option value="free">Free</option> <option value="pro">Pro - $29/mo</option> <option value="enterprise" disabled>Enterprise (Contact us)</option></select>
Attributes
| Attribute |
Purpose |
Example |
name |
Form field name for submission |
name="country" |
required |
Field must have a non-empty value. Needs a placeholder first option with value="" (see below); not applicable to multiple or size > 1 |
required |
disabled |
Prevents selection |
disabled |
multiple |
Allow selecting multiple options |
multiple |
size |
Number of visible options (useful with multiple) |
size="5" |
autocomplete |
Autofill hint |
autocomplete="country" |
With form-field
Wrap a select in the form-field custom element for enhanced validation, required indicators, and helper text.
<form-field> <label for="department">Department</label> <select id="department" name="department" required> <option value="" disabled selected>Select department...</option> <option value="sales">Sales</option> <option value="engineering">Engineering</option> </select></form-field>
Accessibility
- Always use a label: Every select needs an associated label, either wrapping or via
for/id
- Use autocomplete: Add appropriate
autocomplete values for autofill (e.g., country)
- Keyboard navigation: Arrow keys navigate options; typing jumps to matching text
- Option groups: Help screen readers understand option categories
- Avoid onChange submission: Do not submit forms automatically on select change without warning
- Multiple select guidance: Provide visible instructions for Ctrl/Cmd-click
CSS Reference
VB sets appearance: none to remove the native dropdown arrow and draws its own chevron with a currentColor gradient in background-image, so the arrow always matches the text colour: it follows data-mode="dark", themes and forced-colors mode. It sits on the inline-end side and mirrors to the left under dir="rtl". Only single-row selects get it; multiple and size greater than 1 render as a list box with no arrow. The select inherits shared input styles (border, radius, focus ring) from the form layer.
:root { --select-chevron: conic-gradient(from -45deg at 50% 100%, currentColor 90deg, transparent 0); --select-chevron-size: 0.625rem 0.3125rem; --select-chevron-inset: var(--size-s);} select { appearance: none; cursor: pointer;} select:where(:not([multiple]):is(:not([size]), [size="0"], [size="1"])) { padding-inline-end: var(--size-xl); background-image: var(--select-chevron); background-repeat: no-repeat; background-size: var(--select-chevron-size); background-position: right var(--select-chevron-inset) center; &:dir(rtl) { background-position: left var(--select-chevron-inset) center; } @media (forced-colors: active) { forced-color-adjust: none; color: FieldText; background-color: Field; border-color: FieldText; }} select:disabled { cursor: not-allowed;} optgroup { font-weight: 600;}
Custom chevron
To swap the arrow, set --select-chevron to any image and --select-chevron-size to match. A url() image cannot see currentColor, so give it an explicit colour that works in both modes.
.brand-form select { --select-chevron: url("/icons/chevron-down.svg"); --select-chevron-size: 1rem;}
Customizable Select
Chrome 135+ ships appearance: base-select, which unlocks full CSS control over the dropdown picker, options, checkmark icon, and open/close animations — while retaining native semantics, keyboard navigation, form participation, and accessibility.
VB wraps all customizable-select styles in @supports (appearance: base-select), making this a zero-risk progressive enhancement. Non-supporting browsers keep the existing appearance: none + currentColor chevron.
What Changes Automatically
- Dropdown picker gets surface background, border, radius, shadow, and max-height scroll
- Options gain hover highlight, checked color, and rounded corners
- Checkmark icon uses
--color-interactive
- Chevron rotates 180° on open
- Picker animates in with opacity + translateY (respects
prefers-reduced-motion)
<optgroup> headers render as uppercase muted section labels with dividers
No markup changes are required: every existing single-row <select> upgrades automatically. List boxes (multiple, or size greater than 1) are not upgraded and keep appearance: none.
Rich Content
For selects with images, icons, or descriptions inside options, add a <button> trigger with <selectedcontent> to mirror the selected option in the closed state.
<select name="language"> <button> <selectedcontent></selectedcontent> </button> <option value="en"> <span aria-hidden="true">🇺🇸</span> English <span class="detail"> — American English</span> </option> <option value="es"> <span aria-hidden="true">🇪🇸</span> Español <span class="detail"> — Spanish</span> </option> <option value="fr"> <span aria-hidden="true">🇫🇷</span> Français <span class="detail"> — French</span> </option></select>
<button> becomes the trigger. VB resets it to a plain content slot inside the select's own box: no padding, border, background, shadow, radius or minimum size. Theme button skins do not reach it, so a rich select is the same height as a plain one
- Do not put
aria-label on the inner button. The <label for> names the select, and browsers ignore names on the trigger
<selectedcontent> automatically clones the selected option's content
- Elements with
class="detail" are hidden in the closed trigger to keep it compact
- Images inside options are sized to
1.5em with border-radius and object-fit: cover
Fallback Without base-select
Browsers without appearance: base-select parse a select with the older rules. The <button> and <selectedcontent> are dropped, and each option collapses to its plain text. The closed select shows the whole option text, including emoji and any .detail text, for example "🇺🇸 English — American English". aria-hidden on spans inside an option is lost with the spans.
- Keep rich option text short and readable on its own, because it is also the fallback label
- Put long descriptions in help text next to the select, not in the option, when they matter in every browser
- Treat images and icons as decoration: the fallback has none of them
Styling Reference
The base-select value exposes these pseudo-elements and states:
| Selector |
What It Targets |
::picker(select) |
The dropdown popup container |
::picker-icon |
The built-in chevron arrow |
::checkmark |
The selected-option indicator |
:open |
Select while picker is visible |
selectedcontent |
Cloned content of selected option in trigger |
Select vs Combo Box
Use this table to decide between the native customizable select and VB's combo-box web component.
| Capability |
Customizable Select |
combo-box |
| JavaScript required |
No |
Yes |
| Filterable / searchable |
No (type-ahead only) |
Yes |
| Rich content in options |
Yes (images, icons, text) |
Yes |
| Form participation |
Native |
Manual (hidden input) |
| Browser support |
Chrome 135+ |
All modern browsers |
| Styled dropdown |
Yes (with @supports gate) |
Yes |
Browser Support
appearance: base-select ships in Chrome 135 (April 2025). Other browsers are implementing it — check caniuse for current status.
VB's implementation is fully gated behind @supports:
@supports (appearance: base-select) { select:not([multiple], [size]:not([size="0"], [size="1"])) { appearance: base-select; }} select:where(:not([multiple]):is(:not([size]), [size="0"], [size="1"])) { background-image: var(--select-chevron);}
Detect in JavaScript:
if (CSS.supports('appearance', 'base-select')) { }
Related
- option - Individual options within a select
- optgroup - Group related options with a label
- selectedcontent - Clone selected option content in the trigger button
- datalist - Autocomplete with custom values
- combo-box - Fully custom filterable dropdown
- form-field - Enhanced select with validation
- label - Required for accessibility
data-show-when - Show a section only when the select has a given value (multi-select aware)
data-autosave - Drafts keep single and multiple selections
multiple - More than one value, and how size interacts with it
required - Must-have-a-value fields, including the placeholder label option