Fieldset
Pilot

View source on GitHub

Fieldset creates a fieldset and legend for a group of related form items, like RadioButtons or CheckBoxes, in order to clearly indicate related form items."

also known as Form group, Input Group, Choice Group, Form Block
Figma:

Web:

iOS:

Android:

A11y:

Props

Component props
Name
Type
Default
children
Required
React.Node
-

The content of Fieldset, typically RadioButtons, Checkboxes or TextFields.

legend
Required
string
-

Caption that clearly and concisely describes the form elements grouped in the fieldset.

errorMessage
string
-

When needed, pass a string with a helpful error message (be sure to localize!).

id
string
""

A unique identifier for this Fieldset. id must be specified when an errorMessage is added.

legendDisplay
"visible" | "hidden"
"visible"

Whether the legend should be visible or not. If hidden, the legend is still available for screen reader users, but does not appear visually. See the legend visibility variant for more info.

Usage guidelines

When to use
  • When inputs within a broader form are closely related and would benefit from a shared legend, such as TextFields for a billing address or a group of Checkboxes.
When not to use
  • When the fields are unrelated. Use TextFields and other input components within a <form/>.

Accessibility

Wrapping form fields in Fieldset creates an accessible grouping that signals to users when certain form items are related. The legend should clearly describe what information is needed from the group of items, whether they're RadioGroup, Checkboxes or TextFields.

In the example below, the pet RadioButtons are surrounded by a fieldset and include a legend of "Favorite pet". Learn more about the use of fieldset and legend.

Localization

Be sure to localize the legend text.

Variants

Legend visibility

By default, the legend is visible above the items in the Fieldset. However, if the form items are labeled by content elsewhere on the page, or a more complex legend is needed, the legendDisplay prop can be used to visually hide the legend. In this case, it is still available to screen reader users, but will not appear visually on the screen.

In the example below, the "Company Account Goals" text is acting as a heading and a legend for the checkboxes, so instead of repeating another legend, we visually hide the Fieldset legend. When a user focuses on the first checkbox, a screen reader will announce "Sell more products, unchecked, checkbox, Choose up to 3 company account goals, group".

Error message

Component quality checklist

Component quality checklist
Quality item
Status
Status description
Figma Library
Component is not currently available in Figma.
Responsive Web
Ready
Component is available in code for web and mobile web.
iOS
Component is not currently available in code for iOS.
Android
Component is not currently available in code for Android.

Label
If a label is needed for a single form item (instead of a group of items), use Label.