Usage
After setting up the CSS, apply dv-native-select to a labeled select. Use option values for the data submitted by the form.
<label for="select-team">Team</label>
<select id="select-team" name="team" class="dv-native-select">
<option value="design">Design</option>
<option value="engineering">Engineering</option>
<option value="support">Support</option>
</select> Examples
Dropdown sizes and states
Use a size class to set the control density. The styled dropdown appears in browsers with customizable select support. The control remains native.
<label>Team
<select name="team" class="dv-native-select dv-native-select--sm">
<option value="design">Design</option>
<option value="engineering">Engineering</option>
<option value="support">Support</option>
</select>
</label>
<label>Archived team
<select class="dv-native-select dv-native-select--lg" disabled>
<option>Operations</option>
</select>
</label> Multiple selection
Use multiple for a native multi-select list and a numeric size attribute to set the visible row count. The attribute and the visual size modifier can be used together.
<label>Teams
<select name="teams" class="dv-native-select" multiple size="3">
<option value="design">Design</option>
<option value="engineering">Engineering</option>
<option value="support">Support</option>
</select>
</label> API reference
| Class or attribute | Behavior |
|---|---|
dv-native-select | Styles the native select and enables the styled picker where supported. |
dv-native-select--smdv-native-select--mddv-native-select--lg | Changes control typography and padding. Medium is the default. |
multiplesize | Native list behavior and visible row count. |
selecteddisabled | Use selected on an option to set its initial selection. Disable the whole control or individual options as needed. |
Customization
Set control tokens on the select. In browsers with the styled picker, option padding uses the same spacing tokens.
| Property | Effect and defaults |
|---|---|
--dv-native-select-padding-block / --dv-native-select-padding-inline | Padding set by the selected size. |
--dv-native-select-background | Surface color computed from the surrounding appearance. |
--dv-radius-md / --dv-color-focus | Shared corner radius and keyboard focus color. |