About the shadcn/ui Field Component

The Field component is part of shadcn/ui — a collection of accessible, copy-paste React components built with Radix UI and Tailwind CSS. Install it with `npx shadcn@latest add field` and copy it directly into your project.

Field Component — Frequently Asked Questions

What does the shadcn Field component do?

Field is a form layout wrapper that groups a label, input control, helper text, and error message into a consistent structure. It handles ARIA associations automatically.

How do I show an error message in a shadcn Field?

Pass `error` and `errorMessage` props to `<Field>`. The component renders the message with error styling and updates the input's `aria-invalid` attribute.

How do I create a required field indicator with shadcn Field?

Add `required` prop to `<Field>`. This typically adds an asterisk (*) to the label and ensures the `required` attribute is set on the underlying input.

Field Component - shadcn/ui Examples | Shadcn Store