<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5HGSQD2L" height="0" width="0" style="display:none;visibility:hidden" title="GTM"></iframe>

Dropdown

A pull-down list of items that appear when the input is selected.

Use Dropdown...

  • To display a list with plain text.
  • To leverage the native browser select functionality.
  • To select a single item from a larger set of items.
  • To submit data within a form.

Don't use Dropdown...

  • To display complex information like titles, sections, thumbnail images, or callouts. Use a Listbox instead.
  • To display links. Use a Menu instead.

Skin

Default

The default Dropdown is styled like other form elements and displays the first option within the Dropdown list.

The preview has been updated.

Line

The preview has been updated.

Size

Use size="mini" to reduce the height of a Dropdown.

The "mini" Dropdown should play a supporting role in the layout, ensuring a clear visual hierarchy. This size works well in situations where there is limited vertical space.

The preview has been updated.

Full width

Use fullWidth to grow a Dropdown to fill it's container.

The preview has been updated.

With floating label

Use DropdownWithFloatingLabel to move the label inside the input. This creates visual harmony with other form elements like text inputs that support floating labels. Keep label text short or use the fullWidth prop to maximize width.

The preview has been updated.

Forms: Error messaging, helper text, and external labels


Dropdown errors, helper text, and external labels should use the standard Form component.

Vanilla API

Refer to Form for more details

React API

In React API, use the FormField components to incorporate external labels, error messages, or helper text. These components automatically apply the necessary aria attributes to the Dropdown, eliminating the need for manual handling.g.

The preview has been updated.

The preview has been updated.

Managing state

As is the case with most form elements, folks often want to "control" this component. Controlling a component means that you take ownership over its state rather than letting the browser manage the state for you. When you control a component, you own the source of truth for the UI. This means that you don't need to query the DOM in order to determine the current value of the element. So, when it comes time to use the value of the element somewhere else (e.g. submitting the selection to a back-end service) you can trust your stored value.

Share

Implementation

For the Vanilla API, if your Dropdown is created after the DOMready event, initialize it by triggering an initializeControl event on it.

Avoid placing a Dropdown inside an element that is a table cell or has CSS display: table-cell. This configuration may result in the Dropdown being rendered more narrowly than its actual minimum width.

Accessibility

See accessibility details for Forms.

Number of listed items

Do

  • Use a Dropdown when listing 5 or more items.

Don't...

  • Use a Dropdown when listing fewer than 4 items. Use a single select Section Set instead, with radio buttons if space permits.
  • Use a Dropdown when listing more than 15 items. This can create a lack of overview and potential scrolling issues. Use a Combobox instead.

Placement

The Dropdown prioritizes usability through generous padding and a large font, resulting in a minimum width determined by the widest option within the Dropdown.

  • Ensure the Dropdown has sufficient room for rendering on the page.
  • Account for the potential length increase in translated text compared to English to prevent display issues.

Props

Dropdown
This component is implemented using the <select /> as the root element. You can utilize the native attributes supported by <select /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
proptyperequireddescriptiondefault
size"standard" | "mini" | nullfalse
⚠️ Deprecated - This is deprecated without a replacement.
Mini will make the dropdown smaller
standard
skin"standard" | "line" | "error" | nullfalse
The error skin will show a red border around the element. skin 'line' is deprecated. Use 'standard' instead
standard
fullWidthboolean | nullfalse
whether or not the component should horizontally to fill its container's availableWidth
null
htmlSizenumberfalse
Specifies the number of visible options in a drop-down list.
null
DropdownFloatingLabel
This component is implemented using the <label /> as the root element. You can utilize the native attributes supported by <label /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
DropdownOption
This component is implemented using the <option /> as the root element. You can utilize the native attributes supported by <option /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
DropdownWithFloatingLabel
This component is implemented using the <div /> as the root element. You can utilize the native attributes supported by <div /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
proptyperequireddescriptiondefault
fullWidthboolean | nullfalse
Whether or not to have the Dropdown expand to fill its container's width
false
Was this page useful?

Thanks for your feedback!

Feel free to include your name if you wish to have a follow up conversation.


Published: Jan 7, 2022Last updated: Oct 17, 2024