Build faster with Premium Chakra UI Components 💎

Learn more
Skip to Content
DocsPlaygroundGuidesBlog
Sponsor

Field

Used to add labels, help text, and error messages to form fields.

SourceStorybookRecipeArk

Setup

If you don't already have the snippet, run the following command to add the field snippet

chakra snippet add field

The snippet includes a closed component composition for the Field component.

Usage

import { Field } from "@/components/ui/field"
<Field>
  <Input />
</Field>

Examples

Error Text

Use the invalid and errorText to indicate that the field is invalid.

This is an error text

Helper Text

Use the helperText prop to add helper text to the field.

This is a helper text

Horizontal

Use the orientation="horizontal" prop to align the label and input horizontally.

Disabled

Use the disabled prop to disable the field.

Textarea

Here's how to use the field component with a textarea.

Native Select

Here's how to use the field component with a native select.

Required

Use the required prop to indicate that the field is required.

Optional

Use the optionalText prop to indicate that the field is optional.

Props

Root

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
disabled
boolean

Indicates whether the field is disabled.

ids
ElementIds

The ids of the field parts.

invalid
boolean

Indicates whether the field is invalid.

readOnly
boolean

Indicates whether the field is read-only.

required
boolean

Indicates whether the field is required.

as
React.ElementType

The underlying element to render.

unstyled
boolean

Whether to remove the component's style.

Previous

Empty State

Next

Fieldset