TextField
A labelled text input with description + error wiring.
Signature
Density
Viewport
Theme and light/dark are set in the top barWhen to use
- Use it when Collect a single line of free text — name, email, search term.
- Reach for something else when A fixed set of choices (
Select/RadioGroup) or long multi-line input.
Accessibility
Always render a visible <label> (the label prop wires htmlFor/id for you). Errors set aria-invalid and are announced via aria-describedby. Required fields expose aria-required.
Install and import
npx shadcn@latest add @prism/text-field
import { TextField } from '@/components/prism/TextField';
In a no-build prototype, read it from the bundle instead: const { TextField } = window.PrismDesignSystem_39d121;
Examples
With description
<TextField label="Work email" type="email"
description="Used only for sign-in." isRequired />
Invalid
<TextField label="Workspace name" isInvalid
errorMessage="This name is already taken." />
Leading icon
<TextField label="Amount" leadingIcon={<DollarSign />} defaultValue="2,400.00" />
Props
| Prop | Type | Required | Description |
|---|---|---|---|
label | React.ReactNode | — | |
description | string | — | Helper text shown under the label; linked via aria-describedby. |
errorMessage | string | — | Shown when isInvalid; linked via aria-describedby + aria-invalid. |
isRequired | boolean | — | Sets native required, so the browser blocks submit while it's empty (like Select's isRequired). |
isInvalid | boolean | — | |
isDisabled | boolean | — | |
multiline | boolean | — | Render a <textarea> instead of <input>. |
leadingIcon | React.ReactNode | — | Icon node placed inside the start of the field. |
type | string | — | |
placeholder | string | — | |
value | string | — | |
defaultValue | string | — | |
onChange | (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void | — | The native change event — e.target.value needs no cast. |
onValueChange | (value: string) => void | — | Fired with the new text on every change. |
isLabelHidden | boolean | — | Keep the label for screen readers but hide it visually (e.g. a field in a table cell). |
descriptionPosition | "above" | "below" | — | "above" (default, between label and input) or "below" the input — use "below" so inputs in a row line up. |
hint | React.ReactNode | — | End of the label row, e.g. a character counter "42 / 30–60". Linked by aria-describedby; not part of the label, not live. |
mono | boolean | — | Monospace input (URLs, JSON, reference codes). |
size | "sm" | "md" | — | "sm": the compact control for table cells. |
id | string | — | |
width | "xs" | "sm" | "md" | "lg" | "full" | — | Maximum width: "xs" (8rem) | "sm" (12rem) | "md" (20rem) | "lg" (36rem) | "full" (default). A cap, not a fixed width — it still shrinks on a phone or in a narrow FormRow column; the label and messages follow it. Sizes are the --field-width-* tokens. |
isReadOnly | boolean | — | Native readOnly: focusable, selectable and submitted, but not editable. |
isCopyable | boolean | — | Adds a Copy button at the end of a single-line field (pay links, URLs, API keys); shows and announces "Copied" for 2s. Ignored for multiline. |
copyLabel | string | — | Accessible name of the Copy button. Default "Copy <label>". |
copiedLabel | string | — | Confirmation text after copying. Default "Copied". |
className | string | — |