Input
A 48 field you type in, label above.
$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/input.jsonDefault
States
Nomor rekening BCA terdiri dari 10 angka.
Error on submit (motion)
Prefix, suffix, optional
Rp
Rp
When to use
- Short text the user TYPES: nama, telepon, email, nomor rekening, money (start="Rp").
- Search in a toolbar (type="search", search icon at the start).
When not to use
- More than one line (alasan, alamat) → Textarea.
- Pick from a fixed list → Select (5+) or SegmentedControl / RadioGroup (2–4).
- A date → DateField (typing a date is not supported).
- A password → PasswordInput (it has the eye, aria-pressed, autoComplete and hide-on-submit). Never build an eye with Input end.
Do and don't
Show a real example valuePlaceholder "Sari Pratiwi" or "250.000": the user sees the format at once.
"Contoh: …" or a red asteriskNever write "Contoh:" in a placeholder. Never mark required fields; mark the optional ones with "(tidak wajib)".
Installation
Add Input with the shadcn CLI (your project needs a components.json and the MaHR theme: https://mahrdesign.faizintifada.com/r/theme.json), or copy the files by hand.
API
Input
import { Input } from "@/components/ui/input"| Prop | Type | Default | Description |
|---|---|---|---|
size | "default" | "sm" | "default" | default 48 in forms. sm 44 in toolbars, beside 44 buttons, Select sm and SegmentedControl (one control height per surface). |
start | ReactNode | – | Inside left: "Rp" or a 20 icon. |
end | ReactNode | – | Inside right: an IconButton (ghost, sm). |
aria-invalid | boolean | – | Error edge. Pair with FieldError and Field invalid. |
readOnly | boolean | – | --muted fill, no edge ("Diatur oleh HR"). |
type · value · onChange · disabled · inputMode … | native input props | – | inputMode="numeric" for money and phone. |
Field
import { Field, FieldControl, FieldLabel, FieldDescription, FieldError } from "@/components/ui/field"| Prop | Type | Default | Description |
|---|---|---|---|
Field invalid · disabled | boolean | – | Hides the description when invalid; dims the label when disabled. |
Field shakeKey | number | string | – | Change it on every failed submit; with invalid, the <FieldControl> shakes once (transitions.dev 12). |
<FieldControl> | div | – | Wraps Input, Textarea, Select or DateField: the element that shakes. useErrorShake(ref, invalid, key) for custom controls. |
FieldLabel optional | boolean | false | Adds "(tidak wajib)". |
FieldError children | ReactNode | – | Render it always. Empty = closed (0 px, no space kept). A message opens the slot by height in 250 ms, so the content below slides down; fixing it closes the slot. A FieldDescription closes while the error opens. Announced by a live region (role="alert"). |