# Field

A shared label, description and validation message around a form control.

- **Use it for**: Wrapping any form control with its label, description and validation message.
- **Not for**: Controls without a visible label, such as a search bar in a toolbar. Try [InputGroup](https://unseenui.com/components/input-group/).

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { Field } from '@stackunseen/ui';
import { Input } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<Field label="Project name" description="Shown on your project page." error={error}><Input value={name} onChange={event => setName(event.target.value)} /></Field>
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `children` (required) | `ReactNode` |  |
| `description` | `ReactNode` |  |
| `disabled` | `boolean` |  |
| `error` | `ReactNode` |  |
| `invalid` | `boolean` |  |
| `label` (required) | `ReactNode` | A Field labels one control. |
| `labelAs` | `"label" \| "span"` | Use "span" for grouped/range controls; their group/thumbs use aria-labelledby. |
| `orientation` | `"horizontal" \| "vertical"` | "horizontal" places a checkbox or switch before its label. |
| `required` | `boolean` |  |

## Keyboard

Tab focuses the native control. Labels are associated with their inputs; disabled controls leave the tab order. Error text remains available through aria-describedby.

## Works with

[Input](https://unseenui.com/components/input/), [Textarea](https://unseenui.com/components/textarea/), [Select](https://unseenui.com/components/select/), [Checkbox](https://unseenui.com/components/checkbox/), [Switch](https://unseenui.com/components/switch/), [Alert](https://unseenui.com/components/alert/), [Button](https://unseenui.com/components/button/), [RadioGroup](https://unseenui.com/components/radio-group/), [TonePad](https://unseenui.com/components/tone-pad/), [Slider](https://unseenui.com/components/slider/), [InputGroup](https://unseenui.com/components/input-group/), [Combobox](https://unseenui.com/components/combobox/)

Page: https://unseenui.com/components/field/
