Skip to content

Input

Download .md

An input takes one line of text, such as a name, an email address or a search term.

  • Use it for short, free text.
  • Use Select when the answer comes from a short list.
  • Always pair it with a Label; a placeholder is not a label.
React

Ke sini kami kirim kabar penting untukmu.

Vue

Ke sini kami kirim kabar penting untukmu.

DoPut the label above the field, where it stays while people type.
Don'tDon't use the placeholder as the label; it disappears as soon as people type.
1234
  1. 1Label above the field
  2. 2Field with an input border
  3. 3Value
  4. 4Caret

Label above the field, the field itself, then an optional hint below it. The field uses input for its border, radius-md for its corners and ring for focus.

There is one style. Invalid fields set aria-invalid, which turns the border and the focus ring destructive.

React Vue Flutter Type Default Use
value / defaultValue v-model / default-value controller / initialValue string none The text.
type type keyboardType string text Keyboard and validation hints.
disabled disabled enabled: false boolean false Blocks typing.
aria-invalid aria-invalid validator boolean false Marks the value as wrong.
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
export default function InputDemo() {
return (
<div className="grid w-full max-w-sm gap-2">
<Label htmlFor="input-demo-email">Email</Label>
<Input id="input-demo-email" type="email" aria-describedby="input-demo-hint" />
<p id="input-demo-hint" className="text-sm text-muted-foreground">
Ke sini kami kirim kabar penting untukmu.
</p>
</div>
)
}
Terminal window
npx shadcn@latest add https://design.sosialoka.tech/r/react/input.json
  • Link the label with htmlFor (React) or for (Vue) and the field’s id.
  • Link the hint with aria-describedby so screen readers read it.
  • Error text comes from the backend; show it below the field and set aria-invalid.