2.7.0
Selects afford a single selection from a predefined list of options.
See Forms for guidance on composing full forms.
Use when affording a single selection from a predefined list of options.
<div class="mds-form__select">
<select class="mds-form__select-input">
<option class="mds-form__select-option" value="">Select an Expense Type</option>
<option class="mds-form__select-option" value="vacation">Vacation</option>
<option class="mds-form__select-option" value="public_college">Public College</option>
<option class="mds-form__select-option" value="private_college">Private College</option>
<option class="mds-form__select-option" value="medical">Medical</option>
</select>
<div class="mds-form__select-visual-wrap"></div>
<span class="mds-form__select-open-indicator">
<svg class="mds-icon mds-form__select-open-icon" aria-hidden="true">
<use xlink:href="/icons/mds.svg#caret-down--s">
</use>
</svg>
</span>
</div>
<div class="mds-form__select">
<select class="mds-form__select-input" disabled>
<option class="mds-form__select-option" value="">Select an Expense Type</option>
<option class="mds-form__select-option" value="vacation">Vacation</option>
<option class="mds-form__select-option" value="public_college">Public College</option>
<option class="mds-form__select-option" value="private_college">Private College</option>
<option class="mds-form__select-option" value="medical">Medical</option>
</select>
<div class="mds-form__select-visual-wrap"></div>
<span class="mds-form__select-open-indicator">
<svg class="mds-icon mds-form__select-open-icon" aria-hidden="true">
<use xlink:href="/icons/mds.svg#caret-down--s">
</use>
</svg>
</span>
</div>
Sizing affects select size, text size and internal spacing. The default size is medium, and you can use modifier classes or props to make the button smaller or larger.
<div class="mds-form__select mds-form__select--small">
<select class="mds-form__select-input" id="small-select">
<option class="mds-form__select-option" value="">Select an option</option>
<option class="mds-form__select-option" value="option_1">Option 1</option>
<option class="mds-form__select-option" value="option_2">Option 2</option>
</select>
<div class="mds-form__select-visual-wrap"></div>
<span class="mds-form__select-open-indicator">
<svg class="mds-icon mds-form__select-open-icon" aria-hidden="true">
<use xlink:href="/icons/mds.svg#caret-down--s">
</use>
</svg>
</span>
</div>
aria-describedby
attribute on each select
that has an .mds-form__microcopy
or an .mds-form__field-error
component providing additional information. The value of the aria-describedby
attribute must match the id
attribute on the .mds-form__microcopy
or .mds-form__field-error
component.for
attribute on each label
with a value matching the id
attribute on the corresponding select
.mds-form__field-group
container.<div class="mds-form__field-group">
<label class="mds-form__label" for="expense-type">Expense Type</label>
<select class="mds-form__select-input" id="expense-type">
<option class="mds-form__select-option" value="">Select an Expense Type</option>
<option class="mds-form__select-option" value="vacation">Vacation</option>
<option class="mds-form__select-option" value="public_college">Public College</option>
<option class="mds-form__select-option" value="private_college">Private College</option>
<option class="mds-form__select-option" value="medical">Medical</option>
</select>
</div>
Class |
Applies to |
Outcome |
---|---|---|
|
|
Adjusts styling to render a small select. |
|
|
Adjusts styling to render a large select. |
Prop | Type | Validation | Default | Description |
---|---|---|---|---|
|
String |
–– |
–– |
A space separated list of element |
|
Boolean |
–– |
–– |
Adds |
|
String |
–– |
–– |
A space-separated list of class names that will be appended to the default |
|
Boolean |
–– |
|
If |
|
String |
–– |
|
The |
|
String |
–– |
–– |
Adds an |
|
Array |
–– |
–– |
An array to be rendred as |
|
Boolean |
–– |
|
If true, adds the |
|
String |
Enum: |
|
Alters the size of the select. |
|
String |
–– |
–– |
The value of the option selected. Omitting this selects an empty value option. Set the text for this empty value option using the |
ariaDescribedby
would be written as aria-describedby
.If no value is provided for the id
prop the component will automatically generate one for you.
Setting options and selected value:
<mds-select options=”[{‘Option 1’, ‘option_1’}, {‘Option 2’, ‘option_2’}, {‘Option 3’, ‘option_3’}]” value=”option_2”></mds-select>
Setting placeholder and options:
<mds-select placeholder=”Choose...” options=”[{‘Option 1’, ‘option_1’}, {‘Option 2’, ‘option_2’}, {‘Option 3’, ‘option_3’}]”></mds-select>
box-shadow
property to create an outline. Internet Explorer and Safari have known issues rendering these outlines when using the browser's zoom functionality. This visual defect doesn't affect the functionality of the component.