Input
FreeNewA text field in three sizes with hover, focus, invalid, read-only and disabled states.
Installation
pnpm dlx shadcn@latest add @viewport/input
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above.
import { Input } from "@/components/viewport/input";
export default function InputDemo() {
return (
<div className="flex w-full max-w-sm flex-col gap-3">
<Input aria-label="Full name" placeholder="Full name" autoComplete="name" />
<Input aria-label="Work email" type="email" defaultValue="mara@northwind" aria-invalid autoComplete="email" />
<div className="grid grid-cols-2 gap-3">
<Input aria-label="City" size="sm" placeholder="Small" />
<Input aria-label="Country" size="lg" placeholder="Large" />
</div>
<Input aria-label="Workspace ID" defaultValue="ws_7Fq2Lm" readOnly />
<Input aria-label="Seats" placeholder="Disabled" disabled />
</div>
);
}Props
| Prop | Type | Default |
|---|---|---|
| size | keyof typeof sizesControl height. All sizes use 16px text on phones so iOS does not zoom the page on focus. | "md" |
Accessibility
- A native input: set `aria-invalid` for the error state, or wrap it in Field.
- 16px text on phones, so iOS does not zoom the page on focus.
- Server component with no client JavaScript.
- Respects prefers-reduced-motion.