forms

Tailwind CSS Select

A select element is utilized to choose a value from a range of options.

Class Name
Type
Description
form-controlComponentContainer element.
labelComponentFor helper text.
selectComponentBasic select field.
select-floatingComponentFloating select field.
select-filledComponentSelect with background color and floating label.
select-floating-labelComponentFloats the label to the top.
select-filled-labelComponentKeeps the label at the top.
select-filled-focusedComponentAdds animation to the bottom border of a floating filled select.
select-xsResponsiveSmaller select size.
select-smResponsiveSmaller select size.
select-lgResponsiveLarger select size.
is-validModifierAdds success style to the input.
is-invalidModifierAdds error style to the input.

Basic select example.

The <select> element’s customization options are primarily confined to its initial appearance. Due to browser constraints, modifications to the appearance of <option> elements within the dropdown are not possible.

The label remains in its floated position at all times, unlike with input elements. Pair select-floating with your select element and select-floating-label for the label.

Apply the select-filled class to give your select element a background, and use select-filled-label for the label that will float above the text.

Default select has 4 size default, small and large.

Floating select has 3 sizes example.

Filled select has 3 sizes example.

Success state which can be added by using class is-valid.

Error state can be added using class is-invalid.

Use the rounded-full utility class to make select’s circular. The default shape of the select but can be altered by using TailwindCSS Border Radius.

The form-control acts as a wrapper for the label and the select elements. Inside this wrapper, the label class is styled in two ways: label-text is used for the select’s label, and label-text-alt is for the additional helper text.

label elements hidden using the .sr-only class.

Disable a select element by adding the disabled attribute, making it non-selectable.

Associate a datalist element with an input to provide a list of suggested options, allowing users to select from predefined choices or enter a custom value.

Enable the selection of multiple options in a select element by adding the multiple attribute.

Utilize the optgroup element to group option elements together within a select dropdown, creating organized sections.