forms

Tailwind CSS Input

A fundamental tool for receiving user input is a text field, which allows data to be provided or altered using either the keyboard or mouse.

Class Name
Type
Description
inputComponentBase class for form input.
input-floatingComponentBase class for floating form input.
input-floating-labelPartFloats the label to the top.
label-textPartBase class for title label text.
helper-textPartBase class for helper label text.
no-focusModifierremove default focus from input.
is-validStateAdds success style to the input.
is-invalidStateAdds error style to the input.
input-xsSizeInput with Extra small size.
input-smSizeInput with Smaller size.
input-mdSizeInput with medium(default) size.
input-lgSizeInput with Larger size.
input-xlSizeInput with Extra large size.

Utilize the input component class to style the input.

Basic input with placeholder.

Please use label-text for the label and helper-text for the text that appears at the bottom as helper text.

label elements hidden using the .sr-only class.

Default Input.

The Floating Input Component provides a text input with a floating label. Use .input-floating for the wrapper, .input for the input field, and .input-floating-label for the label.

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

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

Success state can be show using is-valid class.

Error state can be show using is-invalid class.

To create an input group, use input as a wrapper. To align the label or icons, apply the my-auto class. This ensures consistent vertical alignment within the group.

Add a leading icon inside input.

Add a trailing icon inside input.

Add a leading and trailing icon inside input.

Utilizes kbd component class with input.

Place any checkbox or radio option within an input group’s addon instead of text.

This example demonstrates an inline select component. The .input class serves as a wrapper, incorporating pe-0 for padding reset and items-center for vertical alignment. Additionally, ms-3 is used to manage spacing.

We can manage the input’s radius using the rounded utility class provided by Tailwind CSS.

Implement varying input styles accompanied by helper text.

Disable the default focus on the input using no-focus class when necessary.

Add the disabled boolean attribute on an input to remove pointer events, and prevent focusing.

Add the readonly boolean attribute on an input to prevent modification of the input’s value.

Combine a button with the input field using the join method.

Combine a button with the input input.

Combine a select with the input input.