Skip to main content

TextField

A labelled text input with description + error wiring.

Signature
Density
Viewport
Theme and light/dark are set in the top bar
Live demo
Open ↗

When 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​

PropTypeRequiredDescription
labelReact.ReactNode—
descriptionstring—Helper text shown under the label; linked via aria-describedby.
errorMessagestring—Shown when isInvalid; linked via aria-describedby + aria-invalid.
isRequiredboolean—Sets native required, so the browser blocks submit while it's empty (like Select's isRequired).
isInvalidboolean—
isDisabledboolean—
multilineboolean—Render a <textarea> instead of <input>.
leadingIconReact.ReactNode—Icon node placed inside the start of the field.
typestring—
placeholderstring—
valuestring—
defaultValuestring—
onChange(e: React.ChangeEvent&lt;HTMLInputElement | HTMLTextAreaElement&gt;) =&gt; void—The native change event — e.target.value needs no cast.
onValueChange(value: string) =&gt; void—Fired with the new text on every change.
isLabelHiddenboolean—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.
hintReact.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.
monoboolean—Monospace input (URLs, JSON, reference codes).
size"sm" | "md"—"sm": the compact control for table cells.
idstring—
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.
isReadOnlyboolean—Native readOnly: focusable, selectable and submitted, but not editable.
isCopyableboolean—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.
copyLabelstring—Accessible name of the Copy button. Default "Copy <label>".
copiedLabelstring—Confirmation text after copying. Default "Copied".
classNamestring—