ClickorAltL

Dragto resize

Nord Design System SearchDeveloperDeveloperGetting startedUsing Web ComponentsWebfontsCDNLocalizationCSS Framework Legacy ESLint PluginWorking with AIFAQDesignDesignGetting startedFoundationsThemesBrand assetsToolsComponentsComponentsAccordion New Aside New Autocomplete New AvatarBadgeBanner Updated ButtonButton GroupCalendar Updated CardCheckbox Updated Collapsible New Combobox New Command MenuDate Picker Updated Date Range Picker New DividerDrawerDropdownEmpty StateField New FieldsetFilter Bar New FooterHeaderIconInput Updated Item New Kbd New LayoutMessageMeter New ModalNavigationNotificationNumber Field New Otp Field New Outline New Pagination New Popout Updated ProgressProgress BarQrcodeRadio Updated Range Updated Scroll Area New Segmented ControlSelect Updated SkeletonSpinnerStackTabTableTagTextarea Updated Time Picker New ToastToggle Updated TooltipTop BarTruncate New Visually HiddenDesign TokensDesign TokensTailwind CSSTailwind CSSBlocksBlocksTemplatesTemplatesIconsIconsPlaygroundPlaygroundLatest UpdatesLatest UpdatesChangelogChangelogMigration guidesMigration guides
GitHub

Select Updated

Open in Storybook

Lets users choose one option from an options menu.

Loading...

Usage

Select lets users choose a single option from a menu. Consider using it when you have five or more options to choose from. Place <option> elements in the default slot, and use value to set the initial selection. For a small number of mutually exclusive options, consider Radio buttons instead.

The select renders its built-in label, hint and error on its own. Wrapped in a Field, the Field takes over with a Field Label, Field Description and Field Error, and the built-in versions step aside automatically.

Copy code
import "@nordhealth/components/lib/Select"
import "@nordhealth/components/lib/Field"
import "@nordhealth/components/lib/FieldLabel"
import "@nordhealth/components/lib/FieldDescription"

Standalone or inside a Field

Use the control on its own with its built-in label, hint and error, or wrap it in a Field — the Field then provides the labelling. Both render the same control:

InlineWith Field

Examples

Basic

A select with a connected Field Label and a list of <option> choices.

Autocomplete

Set autocomplete to let the browser suggest and fill a previously entered value.

Sizes

Use the size attribute to render a small, medium (default) or large select.

Hint

Add a Field Hint to give the user extra guidance about the field.

Required

Set required on the Field Label to show the required indicator and mark the control required.

Hidden label

To hide the label visually while keeping it available to assistive technology, connect a Field Label with for and visually hide it.

Custom width

Constrain or expand the select by setting a custom width on the control.

Custom button style

Customise the trigger appearance with CSS custom properties or parts.

Custom icon

Replace the default chevron with a custom icon via the icon slot.

In a form

Use the select inside a <form> to submit its value alongside other fields.

Placeholder

Use placeholder to prompt the user to make a choice before any option is selected. It is not a replacement for a Field Label.

Error

Show validation with a Field Error and mark the Field invalid.

Disabled

A disabled select cannot be focused or changed and is excluded from form submission.

Expand

Use expand to make the select fill the width of its container.

RTL

Select follows the document or container direction. Toggle the direction to see the layout mirror.

Accessibility

  • Always give the select an accessible name with a Field Label connected via for.
  • Convey validation with a Field Error rather than colour alone — it is associated with the select and announced to assistive technology.
  • Mark required fields by setting required on the Field Label; it shows the indicator and marks the control required.
  • Give every <option> clear, descriptive text, and use a placeholder rather than an empty option to prompt for a choice.
  • For a small number of mutually exclusive options, consider Radio buttons instead, which expose all choices at once.

API reference

Select

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

<nord-select></nord-select>

Props

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'
placeholderplaceholderPlaceholder text to display within the control.string | undefined
requiredrequiredDetermines whether the control is required or not. A required control is announced as such to assistive technology and, inside a <nord-field>, drives the required indicator on the <nord-field-label>. 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
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

Field properties

PropertyAttribute Description TypeDefault
labellabelLabel for the control. Ignored when the control is wrapped in a <nord-field>, which provides the label via <nord-field-label>.string''
hinthintOptional hint text shown with the control. Ignored inside a <nord-field>, which provides it via <nord-field-description>.string | undefined
hintBelowhint-belowRenders the hint below the control and any error instead of below the label.booleanfalse
hideLabelhide-labelVisually hide the label, but still expose it to assistive technologies.booleanfalse
errorerrorOptional error shown with the control. Ignored inside a <nord-field>, which provides it via <nord-field-error>.string | undefined
hideRequiredhide-requiredVisually hide the required indicator, but still expose the required state to assistive technologies.booleanfalse

Slots

Slot name Description
Default slotDefault slot for holding
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)
Design guidelinesFor designers

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.

Hint placement

Hint text is rendered above the control by default to preserve existing behavior for current consumers. Use the hint-below property to opt in to rendering the hint below the control and any error.

This is a non-breaking rollout for teams adopting the new layout gradually. Existing integrations keep the current placement unless hint-below is explicitly set.

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: