Field

Field is a component used to group form elements with label, helper message, error message, etc.

Usage

import { Field } from "@yamada-ui/react"
<Field.Root>
  <Field.Label />
  <Field.HelperMessage />
  <Field.ErrorMessage />
</Field.Root>

Displaying a Helper Message

To display a helper message, set a ReactNode to helperMessage.

We'll never share your email.

Alternatively, you can customize using Field.HelperMessage.

We'll never share your email.

Displaying an Error Message

To display an error message, set invalid to true and assign a ReactNode to errorMessage.

Email is required.

Alternatively, you can customize using Field.ErrorMessage.

Email is required.

Replacing Helper and Error Messages

Error messages are only displayed when invalid is true. To replace the helper message with the error message when the error message is displayed, set replace to true. By default, it is set to true.

Email is required.
We'll never share your email.Email is required.

Required

To make it required, set required to true.

We'll never share your email.

Disable

To disable, set disabled to true.

We'll never share your email.

Read-Only

To make it read-only, set readOnly to true.

We'll never share your email.

Change Direction

To change the direction, set orientation to "horizontal" or "vertical". By default, "vertical" is set.

We'll never share your email.
We'll never share your email.

Customize the Label

To customize the label, use Field.Label.

Customize the Required Indicator

To customize the required indicator, set a ReactNode to requiredIndicator.

Use Optional Indicator

To use an optional indicator, set a ReactNode to optionalIndicator.

Props

Accessibility

ARIA Roles and Attributes

ComponentRoles and AttributesUsage
FieldRequiredIndicatorrole="presentation"Indicates that this is a presentation element.
aria-hiddenExcludes the element from the accessibility tree.
Field.ErrorMessagearia-live="polite"Indicates that it may be updated outside of focus.

Similar Components

Fieldset

Fieldset is a component used to group elements such as legends, helper messages, and error messages in a fieldset element.

Form

Form is a component used to group multiple form elements.

Bleed

Bleed is a component used to extend elements beyond the boundaries of a container.

Box

Box is the most abstract component on which all other components are built. By default, it renders a div element.

Center

Center is a component that aligns the child elements in the center within the component.

Container

Container is a component used as a general division element. By default, it renders the section element.

Flex

Flex is a component that sets flex to Box. Also, convenient style shorthand is available.

Float

Float is a component used to fix elements to the edges of a container.

Uses Components & Hooks

Used By Components & Hooks

Autocomplete

Autocomplete is a component used to display suggestions in response to user text input.

Calendar

Calendar is a component for displaying or selecting dates in a calendar.

Checkbox

Checkbox is a component used for allowing users to select multiple values from multiple options.

ColorPicker

ColorPicker is a component used by the user to select a color or enter an arbitrary color value.

DatePicker

DatePicker is a component used for users to select a date.

Dropzone

Dropzone is a component used for uploading files via drag and drop.

Editable

Editable is a component used to obtain inline editable text input.

Fieldset

Fieldset is a component used to group elements such as legends, helper messages, and error messages in a fieldset element.

FileButton

FileButton is a button component used for users to select files.

FileInput

FileInput is a component used for users to select files.

Input

Input is a component used to obtain text input from the user.

NativeSelect

NativeSelect is a component used for allowing users to select one value from a list of options. It displays a native dropdown list provided by the browser (user agent).

NumberInput

NumberInput is a component used to obtain numeric input from the user.

PasswordInput

PasswordInput is a component that allows users to input passwords with a visibility toggle.

PinInput

PinInput is a component used to capture pin codes or OTP (One-Time Password) inputs.

Radio

Radio is a component used for allowing users to select one option from multiple choices.

Rating

Rating is a component used to allow users to provide ratings.

SaturationSlider

SaturationSlider is a component used to allow the user to select a color saturation.

SegmentedControl

SegmentedControl is a component used for allowing users to select one option from multiple choices.

Select

Select is a component used for allowing a user to choose values from a list of options.

Slider

Slider is a component used for allowing users to select a value from a range.

Switch

Switch is a component used to toggle between on and off states.

Textarea

Textarea is a component used to obtain multi-line text input.

Toggle

Toggle is a component that has two states: on or off.