forms

Tailwind CSS Select

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

Class Name
Type
Description
selectComponentBasic select field.
select-floatingComponentFloating select field.
select-floating-labelPartFloats the label to the top.
label-textPartFor label.
helper-textPartFor helper text.
is-validStateAdds success style to the input.
is-invalidStateAdds error style to the input.
select-xsSizeExtra small select size.
select-smSizeSmaller select size.
select-mdSizeMedium(default) select size.
select-lgSizeLarger select size.
select-xlSizeExtra large select size.

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.

Add responsive class select-{size} where {size} = xs|sm|md|lg|xl for select of different sizes.

Add responsive class select-{size} where {size} = xs|sm|md|lg|xl for select of different sizes.

Add a leading icon inside select. There are no tailing icons for select

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.

Use the label-text for the main label and helper-text class for 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.