Uqudo UIregistry

Field

Form field primitives — label, description, error and layout.

Choose a unique username for your account.

Must be at least 8 characters long.

Installation

npx shadcn@latest add @uqudo/field

Installing it also installs Label and Separator, which it depends on.

Usage

import {
  Field,
  FieldDescription,
  FieldError,
  FieldGroup,
  FieldLabel,
} from "@/components/uqudo/ui/field"
<FieldGroup>
  <Field>
    <FieldLabel htmlFor="email">Email</FieldLabel>
    <Input id="email" type="email" />
    <FieldDescription>We will never share it.</FieldDescription>
    <FieldError errors={[{ message: "Enter a valid email." }]} />
  </Field>
</FieldGroup>

Field works with any control: Input, Textarea, Select, Checkbox, Switch and so on. Set data-invalid="true" on the Field to tint the label red.

Examples

Horizontal

Use orientation="horizontal" for controls that sit next to their label, such as a checkbox or a switch. FieldContent stacks the label and description.

You agree to our terms of service and privacy policy.

Receive a weekly summary by email.

Error

FieldError accepts an errors array, deduplicates messages and renders a list when there is more than one.

Field set

Group related fields with FieldSet and FieldLegend. FieldSeparator draws a rule between fields, optionally with a label in the middle.

Shipping address

Where should we send your order?

Optional

API Reference

Field

Prop

Type

FieldLabel

Prop

Type

FieldError

Prop

Type

FieldLegend

Prop

Type

FieldSeparator

Prop

Type

Layout helpers

ComponentRendersNotes
FieldGroup<div>Vertical stack of fields with consistent spacing. Container query root.
FieldSet<fieldset>Semantic group for a FieldLegend and its fields.
FieldContent<div>Stacks label and description beside a horizontal control.
FieldTitle<div>Label-styled text for when there is no control to point htmlFor at.
FieldDescription<p>Muted helper text.

Data attributes

AttributeElementValue
data-slotevery partfield, field-label, field-error, …
data-orientationFieldThe resolved orientation.
data-variantFieldLegendThe resolved variant.
data-contentFieldSeparatortrue when it has children.

On this page