Fieldset

Groups related controls under a shared legend.

Personal information
import * as stylex from "@stylexjs/stylex"
import { Fieldset, FieldsetLegend } from "@/components/ui/fieldset"
import { Field, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"

const styles = stylex.create({ fieldset: { width: "20rem" } })

export default function FieldsetDemo() {
  return (
    <Fieldset xstyle={styles.fieldset}>
      <FieldsetLegend>Personal information</FieldsetLegend>
      <Field>
        <FieldLabel>First name</FieldLabel>
        <Input placeholder="Emmy" />
      </Field>
      <Field>
        <FieldLabel>Last name</FieldLabel>
        <Input placeholder="Noether" />
      </Field>
    </Fieldset>
  )
}

Installation

pnpm dlx shadcn@latest add @arene/fieldset

Needs the arene setup first. Also adds Stack.

Usage

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

import { Input } from "@/components/ui/input"

;<Fieldset>
  <FieldsetLegend>Personal information</FieldsetLegend>
  <Field>
    <FieldLabel>First name</FieldLabel>
    <Input />
  </Field>
</Fieldset>

Anatomy

Fieldset contains a FieldsetLegend followed by related Field controls.

API reference

Accepts Base UI Fieldset props, including render, plus xstyle, className and inline style.

Fieldset

PropTypeDefault
gapSpacingStep4

FieldsetLegend

PropTypeDefault
variant"legend" | "label""legend"

fieldsetStyles

KeyWhat it is
rootShrinkable fieldset
legendLegend weight and bottom space
variantsLegend and label type sizes

Data attributes

AttributeOnEffect
data-slot="fieldset"rootFieldset anatomy
data-slot="fieldset-legend"legendLegend anatomy
data-variantlegendType size
data-disabledroot and legendBase UI disabled state