Fieldset

A labelled group of fields, disabled as one.

Source
$npx @dinachi/cli@latest add fieldset
Personal Information
FieldsetLegend
disabled

Usage

import { Field, FieldControl, FieldLabel } from "@/components/ui/field"
import { Fieldset, FieldsetLegend } from "@/components/ui/fieldset"

export function Shipping() {
  return (
    <Fieldset>
      <FieldsetLegend>Shipping address</FieldsetLegend>
      <Field name="street">
        <FieldLabel>Street</FieldLabel>
        <FieldControl />
      </Field>
      <Field name="city">
        <FieldLabel>City</FieldLabel>
        <FieldControl />
      </Field>
    </Fieldset>
  )
}

Examples

Personal Information
A legend over a group of fields.
import { Fieldset, FieldsetLegend } from '@/components/ui/fieldset';
import { Field, FieldLabel, FieldControl } from '@/components/ui/field';

export function Example() {
  return (
    <Fieldset className="w-full max-w-sm">
      <FieldsetLegend>Personal Information</FieldsetLegend>
      <Field>
        <FieldLabel>First Name</FieldLabel>
        <FieldControl placeholder="John" />
      </Field>
      <Field>
        <FieldLabel>Last Name</FieldLabel>
        <FieldControl placeholder="Doe" />
      </Field>
    </Fieldset>
  );
}

Notes

Agents

Not a control of its own. The agent reports the legend as in on each control inside, so two City fields stay distinct: one in Shipping address, one in Billing address.

API

disabled
agent
boolean = false
Disables every control inside, native inputs and Fields.
renderReactElement
Swap the element, keep the behaviour.

Accessibility

  • A native <fieldset>; the group and its disabled state are announced.
  • FieldsetLegend is a freely styleable <div> that names the fieldset via aria-labelledby.
  • Disabled, the browser disables native controls inside and every Field reads the state.