Skip to content

Selects are styled versions of the select HTML element containing a menu of Options, which can be grouped with Option Group.

Overview

Select combines Calcite styling with robust functionality of a native dropdown.

Usage

  • Interactions that require a native browser selection
  • Form selection

Sample

Best practices

Recommendations

Correct Select pair with dropdown
Do use Select when choosing between multiple items.
Avoid Select two items
Avoid using Select for 2 item decisions. Prefer Radio Button for this case.

Accessibility

Keyboard navigation

KeyFunction
Arrow downSelects the next calcite-option. If the current focus is the last calcite-option, focus will not change.
Arrow upSelects the previous calcite-option. If the current focus is the first calcite-option, focus will not change.
HomeSelects the first calcite-option.
EndSelects the last calcite-option.
EnterOpens the component's menu. If the menu is open, selects the currently focused calcite-option.
SpaceOpens the component's menu.
TabMove focus in and out of component.
Tab and ShiftMove focus in and out of component.
EscIf open, closes the component's menu.

Writing and copy

Typically, you don't need placeholder text. Do not rely on placeholder text's contents, because when text is entered it disappears and can be frustrating for your user.

API reference

Properties

PropertyAttributeDescriptionTypeDefault
disableddisabledWhen true, interaction is prevented and the component is displayed with lower opacity.booleanfalse
formformSpecifies the id of the component's associated form. When not set, the component is associated with its ancestor form element, if one exists.string
labelrequiredlabelSpecifies an accessible label for the component.string
labelTextlabel-textSpecifies the component's label text.string
messageOverridesOverrides individual strings used by the component.Record<string, unknown> | undefined
namenameSpecifies the name of the component. Required to pass the component's value on form submission.string
requiredrequiredWhen true and the component resides in a form, the component must have a value in order for the form to submit.booleanfalse
scalescaleSpecifies the size of the component.Scale"m"
selectedOptionread-onlyThe component's selected option HTMLElement.Option
statusstatusSpecifies the status of the input field, which determines the message and icons.Status"idle"
validationIconvalidation-iconSpecifies the validation icon to display under the component.IconName | boolean
validationMessagevalidation-messageSpecifies the validation message to display under the component.string
validityread-onlyThe component's current validation state.MutableValidityState
valuevalueThe component's selectedOption value.string
widthwidthSpecifies the width of the component. [Deprecated] The "half" value is deprecated, use "full" instead.Extract<Width, "auto" | "half" | "full">"auto"

Slots

NameDescription
default (unnamed)A slot for adding calcite-options.
label-contentA slot for rendering content next to the component's labelText.

Styles

NameDescription
--calcite-select-font-sizeSpecifies the font size of calcite-options in the component.
--calcite-select-text-colorSpecifies the text color of calcite-options in the component.
--calcite-select-border-colorSpecifies the component's border color.
--calcite-select-icon-colorSpecifies the component's icon color.
--calcite-select-icon-color-hoverSpecifies the component's icon color when hovered or active.
--calcite-select-background-colorSpecifies the component's background color.
--calcite-select-corner-radiusSpecifies the component's corner radius.
--calcite-select-shadowSpecifies the component's shadow.

Events

NameDescriptionBehavior
calciteSelectChangeFires when the selectedOption changes.bubblescomposed

Methods

NameDescriptionSignature
componentOnReadyCreate a promise that resolves once component is fully loaded.componentOnReady(): Promise<this>
setFocusSets focus on the component.setFocus(options?: FocusOptions): Promise<void>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.