Text field preview

Text field

Label, input, hint, error and character count wired together with the right ids and ARIA; validate inline or pass errors from your form library.

  • Group
    Text fields
  • Origin
    Inspired · Original (this library)
  • License
    MIT
  • Added
    Oct 22
npx shadcn@latest add @deank/text-field

The registry stays private. Install from the repo with a GitHub token — see the README.

Usage

import { TextField } from "@/registry/components/text-field/text-field";

<TextField label="…" />

Props

PropTypeDefaultDescription
labelstring
hint?ReactNodeHelp text under the input
error?stringError message; when set the field is marked invalid
validate?(value: string) => string | undefined | null | falseInline validator; return a message to show or nothing when valid. Runs after first blur.
prefix?ReactNodeLeading adornment, e.g. an icon or "https://"
suffix?ReactNodeTrailing adornment, e.g. a unit or a button
counter?booleanfalseShow a live count when maxLength is set
size?"sm" | "md" | "lg""md"

When to use

Every single-line form input: email, name, URL, amounts with a prefix or unit.

When not to use

Multi-line text (use a textarea); one-time codes (use otp-input); choosing from a list (use filter-menu or a select).

Related

OTP input · Sign-in · Settings panel · Date picker