Displays a text input field
A single-line field built on the native <input>, so it takes every standard attribute: type, placeholder, required, autocomplete, disabled. Set aria-invalid and the border and focus ring turn red, and screen readers announce the field as invalid. With type="file" the browser's file button is styled to match the field. Use it in forms, search and filters; for a label that sits inside the field, see Floating Label Input.
Preview
Installation
Usage
import { Input } from "@/components/ui/input"
export function MyInput() {
return <Input type="email" placeholder="Email" />
}Examples
Default
Disabled
With Label
<div className="grid gap-2">
<Label htmlFor="email">Email</Label>
<Input id="email" type="email" placeholder="email@example.com" />
</div>File Input
With Validation Error
Please enter a valid email address
<div className="grid gap-2">
<Label htmlFor="email">Email</Label>
<Input
id="email"
type="email"
placeholder="email@example.com"
aria-invalid="true"
/>
<p className="text-sm text-destructive">
Please enter a valid email address
</p>
</div>Props
Input accepts all standard HTML attributes for <input>