Back to elements
ElementLayoutFree

Fieldset React component

A grouped form section on the native fieldset: the legend sits in a notch in the border, the group folds away to a one-line summary, a tick appears once it's complete, an error outlines it in coral, and disabling it disables every control inside.

When to use the Fieldset component

Use Fieldset to split long forms into named groups: checkout steps, account settings, onboarding questions. Screen readers announce the legend with every field inside it.

Fold finished groups away with a summary so people can review a long form at a glance, and use disabled to switch off a whole group at once (like a billing address that matches shipping).

Installation

Add the Fieldset component to your project with the shadcn CLI. It lands in components/fieldset.tsx as plain React + Tailwind CSS source you own and can edit.

Install
Copied!
npx shadcn@latest add https://reactframe.com/r/fieldset.json

Or copy the source by hand and install its dependencies:

Install
Copied!
npm install motion clsx tailwind-merge

Props

<Fieldset /> accepts 13 props, all optional.

  • legend
    string
    Default: "Account details"
  • description
    string
    Default: "Used on receipts and when we need to reach you."
  • children
    React.ReactNode
  • collapsible

    Let people fold the group away to its legend (and summary).

    boolean
    Default: true
  • open
    boolean
  • defaultOpen
    boolean
    Default: true
  • onOpenChange
    (open: boolean) => void
  • summary

    Shown beside the legend while collapsed, e.g. what was filled in.

    React.ReactNode
  • disabled

    Disables every control inside (native fieldset behaviour).

    boolean
    Default: false
  • error

    Marks the group invalid and shows this message under it.

    string
  • complete

    A small tick in the legend once the group is complete.

    boolean
    Default: false
  • theme
    "dark" | "light"
    Default: "dark"
Show all 13 props
  • className
    string

FAQ

Why a native fieldset?
It gives the legend its notch in the border, announces the group name to screen readers, and disables every field inside with one attribute while keeping the legend's toggle usable.
What shows when it's collapsed?
The legend and your summary text, so people can still see what they entered. Clicking the legend opens it again.
How are errors shown?
Pass error: the border and legend turn coral and the message appears below, linked to the group for assistive tech.

Related components

Shape Divider
Free
Section Container
Free
Sticky Header
Free
Back to Top
Free
Copy Button
Free
Terminal
Free