Field — dir/ui
Associates a control with its label, description and validation error.
# Field
Associates a control with its label, description and validation error.
Live preview of every variant and state: https://ui.usedir.com/components/field
## Install
```sh
npx shadcn@4.21.0 add lr-run/dir-ui/field#v0.4.0
```
[Registry item with source and dependencies](https://github.com/lr-run/dir-ui/blob/v0.4.0/registry.json)
Requires React 19, Tailwind CSS 4 and shadcn initialized with Base UI: npx shadcn@4.21.0 init --base base --preset base-nova (in Vite, set up the @/* path alias in tsconfig.json and vite.config.ts first). Registry target placeholders resolve through components.json: @ui, @components, @hooks and @lib. Imports below use the conventional @/ prefix for illustration; the CLI rewrites them to your configured aliases. Shared components are installed once through registryDependencies. The installer merges shared theme rules into the stylesheet configured in components.json. Existing files are never forcibly overwritten; review CLI conflicts before accepting changes. No Dir runtime is required.
## Field
```tsx
import { Field } from '@/components/ui/field.tsx'
```
| Prop | Type | Default / required | Notes |
| --- | --- | --- | --- |
| label | string | Required | |
| children | (props: FieldControlProps) => ReactNode | Required | |
| description / error | string | — | |
| required | boolean | false | |
```ts
type FieldControlProps = { id: string; "aria-describedby"?: string; "aria-required"?: boolean; invalid: boolean }
```
Spread the supplied id, aria-describedby, and invalid props onto the input. The caller owns values and validation.