View fulldotdev/ui on GitHub

Input

Displays a form input field or a component that looks like an input field.

Installation

npx shadcn@latest add @fulldev/input

Usage

import { Input } from "@/components/ui/input"
<Input />

Input renders a native input and passes every attribute through, so use type, name, required, and disabled as in HTML. Pair it with Field for a label, description, and error.

Basic

Field

Use Field, FieldLabel, and FieldDescription to create an input with a label and description.

Field Group

Use FieldGroup to show multiple Field blocks and to build forms.

Disabled

Use the disabled attribute to disable the input. To style the disabled state, add data-disabled="true" to the Field component.

Invalid

Use aria-invalid="true" to mark the input as invalid. To style the invalid state, add data-invalid="true" to the Field component.

File

Use type="file" to create a file input.

Inline

Use Field with orientation="horizontal" to create an inline input. Pair with Button to create a search input with a button.

Grid

Use a grid layout to place multiple inputs side by side.

Required

Use the required attribute to indicate required inputs.

Badge

Use Badge in the label to highlight a recommended field.

Input Group

To add icons, text, or buttons inside an input, use Input Group.

Button Group

To add buttons to an input, use Button Group.

Form

A full form example with multiple inputs, a select, and a button.

RTL

API Reference

Source: src/components/ui/input

Input accepts all native input attributes and class. It sets data-slot="input" (override it with data-slot) and renders multiple only when it is truthy.