Select

OverviewExamplesPropertiesSlotsMethodsEventsCSS PropertiesDependenciesUsageIntegration

Select lets users choose one option from an options menu. Consider using select when you have 5 or more options to choose from.

Properties

PropertyAttribute Description TypeDefault
expandexpandControls whether the select expands to fill the width of its container.booleanfalse
sizesizeThe size of the component.'s' | 'm' | 'l''m'
labellabelLabel for the input.string''
hinthintOptional hint text to be displayed with the input. Alternatively use the hint slot.string | undefined
hideLabelhide-labelVisually hide the label, but still show it to assistive technologies like screen readers.booleanfalse
placeholderplaceholderPlaceholder text to display within the input.string | undefined
errorerrorOptional error to be shown with the input. Alternatively use the error slot.string | undefined
requiredrequiredDetermines whether the input is required or not. An input marked as required will be announced as such to users of assistive technology. When using this property you need to also set “novalidate” attribute on a form element to prevent browser from displaying its own validation errors.booleanfalse
hideRequiredhide-requiredVisually hide the required indicator, but still show required attribute to assistive technologies like screen readers.booleanfalse
autocompleteautocompleteSpecifies the data type of the field, so that the browser may attempt to fill out the field automatically on behalf of the user.AutocompleteAttribute'off'
disableddisabledMakes the component disabled. This prevents users from being able to interact with the component, and conveys its inactive state to assistive technologies.booleanfalse
namenameThe name of the form component.string | undefined
valuevalueThe value of the form component.string''
formformGets the form, if any, associated with the form element. The setter accepts a string, which is the id of the form.HTMLFormElement | null

Slots

Slot name Description
Default slotDefault slot for holding <option> elements.
labelUse when a label requires more than plain text.
hintUse when a hint requires more than plain text.
errorOptional slot that holds error text for the input.
iconUsed to place an icon at the start of select.

Methods

Method nameParameters Description
focus(options?: FocusOptions) => voidoptions: An object which controls aspects of the focusing process.Programmatically move focus to the component.
blur() => voidN/AProgrammatically remove focus from the component.
click() => voidN/AProgrammatically simulates a click on the component.
EventDetail TypeDescription
inputNordEventFired as the user types into the input.
changeNordEventFired whenever the input's value is changed via user interaction.

CSS Properties

CSS Custom Properties provide more fine grain control over component presentation. We advise utilizing existing properties on the component before using these.

PropertyDescriptionDefault
--n-select-block-sizeControls the block size, or height, of the select using our spacing tokens.var(--n-space-xl)
--n-select-inline-sizeControls the inline size, or width, of the select.fit-content
--n-label-colorControls the text color of the label, using our color tokens.var(--n-color-text)

Usage

This section includes guidelines for designers and developers about the usage of this component in different contexts.

Do

  • Use to let a user choose one option from an options menu.
  • Use when you have more than 6 options to choose from.
  • Use when you don’t know how many options there will be.
  • Use hint text and placeholder to provide additional, non-critical instructions.

Don’t

  • Don't use a select if you have less than 6 options to choose from. Consider using segmented control or radio components instead, if you have enough space to allow it.

Content guidelines

Select labels act as a title for the select field. Labels should typically be short and in noun form:

Company name
What is your company name?

When writing select labels, always write them in sentence case, not title case. The first word should be capitalized and the rest lowercase (unless a proper noun):

Company name
Company Name

Do not use colons in select labels:

Choose organization
Choose organization:

Integration

For integration guidelines, please see Web Components documentation .

Was this page helpful?

Yes No

We use this feedback to improve our documentation.