Native select

The browser's own select picker, styled to match Input and wired into Field and form submission.

<tp-native-select>
Native select
Default density Compact density Restart from the initial state Show the copyable source

Usage

Author plain option and optgroup children and the component mirrors them into a real native select, so the platform picker, typeahead and mobile wheels all work unchanged. Reach for Select instead when options need icons, descriptions or custom layout. Insert, remove or reorder the authored nodes to update the picker.

Placeholder

placeholder adds a disabled empty first option, so nothing is chosen until the person picks. Add required and the empty value fails validation on submit.

Placeholder
Default density Compact density Restart from the initial state Show the copyable source

Sizes

size sets the control height to match Input and Button. It is independent of the native listbox row count.

Sizes
Default density Compact density Restart from the initial state Show the copyable source

Multiple

multiple renders the native multi-selection listbox and submits one entry per selected value, in option order. Set the value as an array through the value property.

Multiple
Default density Compact density Restart from the initial state Show the copyable source

Forms

Native Select participates in forms like Input: it submits its name, resets to its default and restores on navigation. Listen for tp-value-change to react to changes.

Form value
Default density Compact density Restart from the initial state Show the copyable source
cycle=monthly

Controlled

Set value to own the selection and accept each proposal in onValueChange by assigning event.detail.value. Leave value unchanged to reject a pick; the native picker snaps back to the committed option. Controlled values absent from the options have no native selection and no submitted entry.

Controlled value
Default density Compact density Restart from the initial state Show the copyable source
Current plan: 25 seats.

States

Disabled, read-only and invalid
Default density Compact density Restart from the initial state Show the copyable source

Native selects have no read-only mode, so readonly blocks changes while keeping the value focusable and submitted. Disabled omits it from form data.

API Reference

Every element also accepts motion-policy.

Attributes

AttributePropertyTypeDefaultDescriptiondefault-valuedefaultValueNativeSelectValue | undefined—The initial value of an uncontrolled select, restored on form reset; an array with multiple.multiplemultiplebooleanfalseSelects several values with the native list box instead of a dropdown; the value becomes an array.placeholderplaceholderstring''A disabled first option shown while nothing is selected.labellabelstring'Options'Accessible name when no Field labels the select.sizesize'sm' | 'default''default'Height and text size, matching Input's sizes.

Properties

PropertyTypeDefaultDescriptiononValueChange((event: TpValueChangeEvent<NativeSelectValue>) => void) | undefined—Called with each proposed value before tp-value-change; a controlled owner accepts it by setting value.hostPropertiesRecord<string, unknown>{}Attributes, properties and listeners applied to the inner native select.controlledread-onlyboolean—Whether the application controls value.selectedOptionsread-onlyHTMLCollectionOf<HTMLOptionElement> | null—The native select's selected options.optionsread-onlyHTMLOptionsCollection | null—The native select's options.selectedIndexnumber—Index of the first selected option, as on a native select; setting it proposes that option.

Events

EventTypeDescriptiontp-value-changeTpValueChangeEvent<string | readonly string[]>Cancelable proposal of a new value, before it commits; detail.value, detail.previousValue and detail.reason.tp-field-valueCustomEvent<{ value: string | readonly string[]; previousValue: string | readonly string[]; reason: ChangeReason; }>After a value commits; an enclosing Field tracks its dirty state from it.

Methods

MethodReturnsDescriptionsetValue(value)booleanProposes a value as if chosen in the picker, and returns whether it was accepted.setCustomValidity(message)voidSets a custom validation message; an empty string clears it.

Slots

SlotDescriptiondefaultNative option, optgroup and hr elements declaring the choices.indicatorReplaces the chevron at the end of a single select.

CSS parts

PartDescription::part(native-select)The wrapper around the native select and its chevron.::part(native-select-control)The native select element.::part(native-select-indicator)The chevron at the end of a single select.::part(native-select-option)A native option, including the placeholder.::part(native-select-option-group)A native option group.

Components, widgets and patterns that use this one.