# Field

> Give any control a label, helper text and an error.

- Category: Inputs
- Import: `import { Field } from "@sagui/ui";`
- Page: /components/field

```tsx
import { Field } from "@sagui/ui";

export function Hero() {
  return (
    <div className="flex w-80 flex-col gap-6">
      <Field label="Store code" description="Six letters or numbers.">
        <input className={control} placeholder="NYC001" />
      </Field>
      <Field label="Fax" optional>
        <input className={control} />
      </Field>
      <Field label="Tax ID" error="Enter a 9-digit tax ID.">
        <input className={control} defaultValue="12-34" />
      </Field>
    </div>
  );
}
```

## When to use

- A control that has no label of its own, such as a custom picker or a native input.
- Marking a field optional or adding a hint beside the label.

## When not to use

- Input, Textarea and Select already include a label, description and error. Use their props.

## Installation

Install the package and import the styles once. The [installation guide](/docs/installation) covers the Tailwind setup.

```bash
npm install @sagui/ui
```

## Usage

```tsx
import { Field } from "@sagui/ui";

<Field label="Store code" description="Six letters or numbers." error={error}>
  <input />
</Field>
```

## Accessibility

- The label is linked to the control by id. The description and error are linked with `aria-describedby`, and an error sets `aria-invalid`.
