Input
Displays a form input field or a component that looks like an input field.
Input is a native HTML text field with shadcn styling. HTML types are supported (text, email, url, number, password, tel, search, file…); pass one via type.
Always pair it with a Label for accessibility (via for/htmlFor).
Installation
$ bext ui add input
Copy and paste the following into src/components/ui/input.tsx.
Usage
Anatomy
<Input type="text|email|number|..." name value placeholder disabled required />
API Reference
Input
| Prop | Type | Default | Description |
|---|---|---|---|
| type | "text" | "email" | "password" | ... | "text" | Native HTML type. |
| name | string | — | Name for form submission. |
| value | string | — | Value (controlled) or defaultValue (uncontrolled). |
| placeholder | string | — | Muted placeholder. |
| disabled | boolean | — | Standard HTML. |
| required | boolean | — | Native HTML5 validation. |
| className | string | — | Default: flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-sm shadow-xs. |
Keyboard
| Key | Action |
|---|---|
| Tab | Moves focus in or out. |
| Enter | Submits the parent form (native behavior). |
Accessibility
Always link a <Label htmlFor="id"> to the <Input id="id"> so that clicking the label focuses the field and assistive technologies announce the label.
Examples
Disabled
<Input disabled value="Disabled" aria-label="Disabled input" />
Edit this example live in the bext playground. It compiles and runs entirely in your browser.
The React idiom: same UI, for comparison.
On This Page