Field

Form field wrapper with a label, helper text, an error message, and automatic accessibility linking to its control.

import { Field } from "@plexui/ui/components/Field";

Examples

Overview

size
We'll never share your email with anyone else.

With description

We'll never share your email with anyone else.

With error message

Required

Sizing

size
We'll never share your email with anyone else.

Horizontal layout

orientation

Textarea

Write a short bio for your profile.

Select

Select your primary role.

Label action

Slider

Set your budget range ($200 – 800).

Fieldset

Address Information

We need your address to deliver your order.

Checkbox

Choose which notifications you'd like to receive.

Radio

Select your preferred plan.

Switch

Field group

Get notified when the assistant responds to requests that take time, like research or image generation.
Get notified when tasks you've created have updates.

Validation and Errors

Render prop pattern

For controls that need explicit prop wiring, pass a function as children. The function receives { id, "aria-describedby", "aria-invalid" } which you spread onto the control.

<Field label="Email" errorMessage="Email is required">
  {(fieldProps) => <Input {...fieldProps} placeholder="Enter email..." />}
</Field>

Optical alignment

opticallyAlign="start"
We'll never share your email.

Form example

Payment Method

All transactions are secure and encrypted


Billing Address

The billing address associated with your payment method

Profile settings

Personal Information

Your public profile details

This is the email associated with your account.
Brief description for your profile. Max 160 characters.

Preferences

Customize your experience

Select your preferred appearance.

Notifications

Manage how you receive updates

Receive weekly digests and important updates.
Get real-time alerts in your browser.
Tips, product updates, and promotions.

Create project

General

Basic information about your project

A short summary shown in project listings.
Controls who can see this project.

Team Access

Invite collaborators and set permissions

Add people by email address.
alice@team.com
bob@team.com
Default permissions for new members.

Infrastructure

Deployment and resource configuration

Automatically deploy on push to main branch.

Field configuration

Setup

Define the basic field properties

Unique identifier used in the API. Cannot be changed later.
Human-readable name displayed in the UI.
Value assigned when the field is empty.

Formatting

Input constraints and sanitization rules

Max length cannot exceed 4096.
Strip potentially unsafe HTML tags from input.

Privacy & Access

Control field visibility and mutability

Prevent this field from being redacted.
Value can only be set once and cannot be changed.
Automatically delete the field value after the specified period.

Birthday input

Birthday with validation

Birthday segmented input

/
/

Birthday with selects

API

PropTypeDefaultDescription
labelReactNode—Label text for the field
descriptionReactNode—Helper text below the label; linked via aria-describedby
errorMessageReactNode—Error message below the control; auto-sets aria-invalid on child
labelActionReactNode—Content at the end of the label row, such as a link that acts on the field
size"3xs" | "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl"child's size, else "md"Label font size; defaults to the child control's size
requiredbooleanfalseShows a required asterisk after the label (visual only)
orientation"vertical" | "horizontal""vertical"Layout direction of label and control
opticallyAlign"start" | "end"—Applies optical alignment to the child control via negative margin using its gutter
idstring—Override the auto-generated id used for htmlFor/aria linking
childrenReactElement | (fieldProps) => ReactNode—Form control; receives id, aria-describedby and aria-invalid, plus aria-labelledby unless it has its own name. A render prop receives aria-labelledby to spread
classNamestring—Applied to the root wrapper

Styling

Field reads these component tokens. Override them at any scope to restyle it:

  • --field-error-color: error color (default var(--color-text-danger-outline))
  • --field-error-font-size: error font size (default 0.75rem)
  • --field-error-gap: error gap (default spacing(2))
  • --field-error-icon-size: error icon size (default 1rem)
  • --field-error-line-height: error line height (default var(--font-text-xs-line-height))
  • --field-error-margin-bottom: error margin bottom (default spacing(3))
  • --field-error-margin-top: error margin top (default 0.5rem)
  • --field-error-padding-inline: error padding inline (default 0)
  • --field-horizontal-control-width: horizontal control width (default 240px)
  • --field-horizontal-label-width: horizontal label width (default 120px)
  • --field-label-font-weight: label font weight (default var(--font-weight-medium))