5-day Mini-Course

Build UIs that don’t suck.

Short, tactical video lessons from the creator of Tailwind CSS, delivered directly to your inbox every day for a week.

Get the free course

Select

A commercial license is required to use Tailwind Plus Elements. Purchase Tailwind Plus to obtain a license.

The <el-select> component is a fully accessible replacement for a native <select> element, designed to give you complete control over styling.

Component API

<el-select>

Manages form integration and coordinates with its child components.

Attributes
nameThe form field name for the select when used in forms.
valueThe selected value of the select. Can be read and set programmatically.
Events
inputDispatched when the selected option changes.
changeDispatched when the selected option changes.
CSS variables (Read-only)
--input-widthProvides the width of the input element (read-only).

<el-options>

The options container that handles the popover behavior.

Attributes
popoverRequired to enable the popover behavior.
anchorConfigures the way the options are anchored to the button.
anchor-strategySets the position CSS property of the popover to eitherabsolute (default) or fixed.
CSS variables
--anchor-gapSets the gap between the anchor and the popover.
--anchor-offsetSets the distance that the popover should be nudged from its original position.
Data attributes (Read-only)
data-closedPresent before transitioning in, and when transitioning out.
data-enterPresent when transitioning in.
data-leavePresent when transitioning out.
data-transitionPresent when transitioning in or out.
Methods
togglePopover()Toggles the options visibility.
showPopover()Shows the options.
hidePopover()Hides the options.

<el-option>

Individual selectable option within the select.

Attributes
valueThe value of the option (required for selection).
disabledWhether the option is disabled.
ARIA attributes (Read-only)
aria-selectedPresent when the option is selected.

<el-selectedcontent>

Automatically displays the content of the currently selected option.

Examples

Basic example

To view the complete documentation, you must own a Tailwind Plus license and be signed in.

Positioning the dropdown

To view the complete documentation, you must own a Tailwind Plus license and be signed in.

Setting the dropdown width

To view the complete documentation, you must own a Tailwind Plus license and be signed in.

Adding transitions

To view the complete documentation, you must own a Tailwind Plus license and be signed in.

Disabling the input

To view the complete documentation, you must own a Tailwind Plus license and be signed in.