Field

Connect form controls to labels, supporting text, and validation feedback.

Installation

npx shadcn@latest add @navui/field

Usage

Place a label, one control, and optional supporting text inside Field. Install NavUI Input alongside Field to use the examples on this page.

import { Field, FieldDescription, FieldLabel } from "@/components/navui/field";
import { Input } from "@/components/navui/input";

export function ReportEmail() {
  return (
    <Field name="email">
      <FieldLabel>Report email</FieldLabel>
      <Input type="email" autoComplete="email" />
      <FieldDescription>Weekly activity reports go to this address.</FieldDescription>
    </Field>
  );
}

Examples

With a label

Click the label to focus the input.

With supporting text

FieldDescription tells people how their email address will be used.

We’ll send project updates to this address.

Required field

Set required on the input and call it out in the visible label.

Validation feedback

Select Validate to see FieldError respond to the browser’s email constraint. This example also uses NavUI Button.

Report settings form

Set a delivery schedule, choose what to include, and save or reset the form. This example uses NavUI Input, Select, Checkbox, Switch, Button, and Lucide icons.

Activity reports go to this address.

Report preferences

Email each report at the chosen frequency.

API reference

Foundation component built on UI SDK Field. See the UI SDK Field documentation for the complete inherited API.

Accessibility

  • Use one control per Field so the label, description, and errors describe the same input.