Skip to content
ghostui

Preview

Visible to everyone in this workspace.

Design guidance

Use Field when a control needs a coordinated label, help or validation state. Field.Label keeps Base UI's control association and accepts the same visual required and optional markers as Label. Controls own native constraints. Participating controls such as Input receive label, description and error associations from Field. Use Label when your existing form already owns those relationships.

Choose a placement for the content. Top works for most forms. Left labels stack at narrow widths. IFTA labels stay static inside a control at least 60px high. Placeholder placement hides the visible label but keeps it available to assistive technology.

Installation

Install

Field examples also use the input, select and textarea registry items. Select and textarea remain optional compositions.

Basic usage

Input already participates in Field. Use it directly; reserve Field.Control render composition for a native or custom control that needs registration.

Structures

Field.Root owns placement and field state. Field.Label names its registered control. Field.Control is optional when a composed control already participates in Base UI Field; use its render prop for native controls such as Textarea. Field.Description and Field.Error automatically associate their generated IDs with the control. Field.Validity exposes Base UI validity state. Field.Item labels an individual option in a Field-managed group, such as a checkbox group. Use Fieldset to group separate fields.

Examples

Subtle field

Set variant="subtle" on Field.Root to coordinate Input or Field.Control with its label. An explicit control or label variant overrides the inherited appearance. Field continues to own label, help, disabled and validation relationships.

Required

The marker is visual. The input still needs native required for browser validity.

Optional

Show optional status without changing control validity.

Disabled

Disable the root field so Base UI carries disabled state to its parts and control.

Native validation

Clear the required input and blur to show its missing-value error. Enter a value and blur again to recover.

Top placement

The default placement keeps the label above its control.

Visible to everyone in this workspace.

Left placement

Use this layout for short labels. At narrow widths, the label and control stack.

In-field top-aligned label

Keep the label static inside a control with at least 60px of height.

Placeholder presentation

This placement hides the label visually. The caller supplies placeholder text; use it only when surrounding context keeps the purpose clear after a value is entered.

Textarea

Use Field.Control's render prop so a native Textarea participates in field registration.

Select

Select uses a button trigger, so render a non-native Field.Label and give the trigger an explicit ID. This connects both its accessible name and label activation. The trigger keeps Select's 32px control height.

Response length

Caller-controlled error

Use this when application state owns validation. The example clears the collision while editing and checks it again on blur. Field.Error match displays the caller's message without adding a second validator.

This assistant name is already in use.

Full width

Let the field fill its available container width.

Caller-owned title

Field owns the visible label. Input owns editing. The caller owns the value.

API reference

For inherited behavior and additional part properties, see the Base UI Field API.