# Text Field

> Labeled field that composes input, description, and validation error.

Registry name: `text-field`. HTML docs: https://ui.anuragroy.dev/component/text-field.

## Install

```bash
npx shadcn@latest add https://ui.anuragroy.dev/r/text-field.json
```

If the website is down: `npx shadcn@latest add https://raw.githubusercontent.com/anurag-roy/ui.anuragroy.dev/main/public/r/text-field.json`.

Registry JSON: https://ui.anuragroy.dev/r/text-field.json (GitHub: https://raw.githubusercontent.com/anurag-roy/ui.anuragroy.dev/main/public/r/text-field.json).

## Import

Import paths follow the consumer `components.json` aliases. After a default install:

```tsx
import {
  TextField,
  TextFieldLabel,
  TextFieldInput,
  TextFieldDescription,
  TextFieldError
} from "@/components/ui/text-field"
```

## Usage

```tsx
import {
  TextField,
  TextFieldDescription,
  TextFieldError,
  TextFieldInput,
  TextFieldLabel,
} from "@/components/ui/text-field"

export function Example() {
  return (
    <TextField name="email">
      <TextFieldLabel>Email</TextFieldLabel>
      <TextFieldInput type="email" placeholder="you@example.com" required />
      <TextFieldDescription>We'll never share this.</TextFieldDescription>
      <TextFieldError match="valueMissing">Email is required.</TextFieldError>
    </TextField>
  )
}
```

## API

### TextField

Base UI Field root. Use `name` so the input participates in form submit.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `name` | string | — |  |
| `invalid` | boolean | — | Force an invalid state. |

### TextFieldError

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `match` | ValidityState key \| function | — | When to show the message (e.g. `valueMissing`). |

## See also

- [HTML page](https://ui.anuragroy.dev/component/text-field): Preview and the same docs in the site chrome.
- [Registry item](https://ui.anuragroy.dev/r/text-field.json): Source files and dependencies.
- [Catalog](https://ui.anuragroy.dev/component): All components.
- [llms.txt](https://ui.anuragroy.dev/llms.txt): Agent index for this library.
