This page as markdown: /fieldset.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

Fieldset

Status: stable

Form section panel (Card-like bordered surface) over Base UI Fieldset, with Legend/Description/Content/Footer parts; variant="plain" is the bare group, for a radio group's shared name.

Keywords: fieldset, form group, legend, fields

Usage

Use Fieldset to group related controls under a shared label or explanation.

Best practices

Anatomy

Part Required Description
Fieldset yes The bordered group: a native
whose disabled state reaches every control inside it.
Legend yes FieldsetLegend: the question the group's controls answer, announced before each of them.
Description no FieldsetDescription: muted copy under the legend.
Content yes FieldsetContent: the stacked body, one Field per control.
Footer no FieldsetFooter: the group's actions on a muted wash.

Subcomponents

Name Type Description
FieldsetLegend ComponentPropsWithRef The group's name — the question its controls answer. Base UI renders it as a
wired to the
through aria-labelledby, so a screen reader announces it before each control in the group. This is the whole reason to reach for Fieldset.
FieldsetDescription ComponentPropsWithRef<"p"> Muted supporting copy under the legend.
FieldsetContent ComponentPropsWithRef<"div"> The stacked body holding one Field per control.
FieldsetFooter ComponentPropsWithRef<"div"> Optional right-aligned action bar on a muted wash.

Props

Name Type Default Description
variant "card" | "plain" "card" card is a bordered, raised section with padded parts. plain is the grouping alone (no border, surface or inset) with the legend in the field-label style: the shared name a radio group needs, inside a form that is already framed.
disabled boolean — Disables the whole group. Renders
(native control disabling) and surfaces data-[disabled] for dimming.
render ReactElement | function — Base UI render prop to replace or compose the underlying element.
className string — Merged onto each part via cn() for one-off overrides.

Tokens used

card, card-foreground, border, foreground, muted-foreground, muted

Accessibility

Related

Examples

A grouped question

import { Button, Checkbox, Field, Fieldset, FieldsetContent, FieldsetDescription, FieldsetFooter, FieldsetLegend } from "@sableui/react"

<Fieldset>
	<FieldsetLegend>Notify me about</FieldsetLegend>
	<FieldsetDescription>Pick what reaches your inbox.</FieldsetDescription>
	<FieldsetContent>
		<Field label="Mentions" orientation="horizontal"><Checkbox defaultChecked /></Field>
		<Field label="Replies" orientation="horizontal"><Checkbox /></Field>
		<Field label="Direct messages" orientation="horizontal"><Checkbox /></Field>
	</FieldsetContent>
	<FieldsetFooter>
		<Button>Save preferences</Button>
	</FieldsetFooter>
</Fieldset>

Why a fieldset, and when it is wrong

import { Field, Fieldset, FieldsetContent, FieldsetLegend, Radio, RadioGroup } from "@sableui/react"

// Fieldset groups inputs that are ONE question with multiple parts, and gives
// the group a single accessible name — which is the part you cannot do with a
// div and a heading.

<Fieldset>
  <FieldsetLegend>Digest frequency</FieldsetLegend>
  <FieldsetContent>
    <RadioGroup defaultValue="weekly">
      <Field label="Daily" orientation="horizontal"><Radio value="daily" /></Field>
      <Field label="Weekly" orientation="horizontal"><Radio value="weekly" /></Field>
    </RadioGroup>
  </FieldsetContent>
</Fieldset>

// ✓ Required for radio groups: without a fieldset the options have no shared
//   name, so a screen reader announces "Weekly, radio" with no question.
// ✗ Not for visual grouping of unrelated fields. Use PanelSection on a panel or
//   a Card section on a page; a legend that is really a heading lies to
//   assistive technology about the form's structure.

A radio group's name, without a second box

import { Card, CardContent, Fieldset, FieldsetLegend, RadioCard, RadioGroup } from "@sableui/react"

<Card>
  <CardContent>
    <Fieldset variant="plain">
      <FieldsetLegend>Delivery</FieldsetLegend>
      <RadioGroup defaultValue="standard">
        <RadioCard value="standard" title="Standard" description="3–5 working days" trailing="Free" />
        <RadioCard value="express" title="Express" description="Next working day" trailing="$12.00" />
      </RadioGroup>
    </Fieldset>
  </CardContent>
</Card>