Fieldset

Fieldsets group multiple fields together with a label. This is a light wrapper over the native fieldset and legend elements, but makes the legend element easily stylable.

Give FeedbackBundle Size
Account details
index.tsx

Installation

Base UI components are all available as a single package.

npm install @base-ui-components/react

Once you have the package installed, import the component.

import { Fieldset } from '@base-ui-components/react/Fieldset';

Anatomy

Fieldsets are composed of two components:

<Fieldset.Root>
  <Fieldset.Legend />
</Fieldset.Root>

Usage with Fields

Field components are placed inside the Fieldset component.

<Fieldset.Root>
  <Fieldset.Legend>Account details</Fieldset.Legend>
  <Field.Root>
    <Field.Label>Name</Field.Label>
    <Field.Control />
  </Field.Root>
  <Field.Root>
    <Field.Label>Address</Field.Label>
    <Field.Control />
  </Field.Root>
  <Field.Root>
    <Field.Label>Bio</Field.Label>
    <Field.Control render={<textarea />} />
  </Field.Root>
</Fieldset.Root>

API Reference

FieldsetRoot

The foundation for building custom-styled fieldsets.

PropTypeDefaultDescription
classNameunionClass names applied to the element or a function that returns them based on the component's state.
renderunionA function to customize rendering of the component.

FieldsetLegend

Renders an element that labels the fieldset.

PropTypeDefaultDescription
classNameunionClass names applied to the element or a function that returns them based on the component's state.
renderunionA function to customize rendering of the component.

Contents