forms

Tailwind CSS File input

File inputs enable users to choose files from their device, allowing them to upload documents, images, or other types of files.

Class Name
Type
Description
inputComponentBase class for form input.
input-floatingComponentBase class for floating form input.
label-textPartBase class for title label text.
input-floating-labelPartFloats the label to the top.
helper-textPartBase class for helper label text.
is-validStateAdds success style to the input.
is-invalidStateAdds error style to the input.
file:{tw-utility-class}ModifierAdds tailwind classes to update file 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.

Basic file input example.

Basic file input example with label.

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

Default type.

Floating label example.

Success state can be show using is-valid class.

Error state can be show using is-invalid class.

The file: prefix in Tailwind allows us to style the ::file-selector-button, and it can be combined with the btn class.

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

Placement of helper text and label.

Add multiple attribute to select more then 1 file.

The following example showcases a file input with an avatar.