Text Field
FreeA labeled text input with clear focus and placeholder states.
npx shadcn@latest add @ui-shrushank/text-fieldThe install writes a single file to components/ui/TextField.tsx, which exports TextField.
tsx
import { TextField } from "@/components/ui/TextField";tsx
<TextField label="Label" />The labelled input baseline.
Always a real <label>, distinct focus and placeholder states, custom focus ring with the browser outline suppressed.
Every line below was read out of the file you are about to copy, so you can check each one against the source at the bottom of this page.
- Draws a
focus-visiblering that is separate from its hover treatment, so keyboard users get an affordance mouse users do not take away. - Pairs every input with a real
<label>, so the field keeps its name after the placeholder disappears.
Placeholder text is not a label substitute (it vanishes on type); pairing them removes the "what was this field?" problem once the user starts typing.
1 required, 0 optional.
| Prop | Type | Default |
|---|---|---|
labelrequired | string | none |
labelrequiredstring
One file, no runtime package. Copy it, or install it with the command at the top of this page.
TextField.tsx
TypeScript