Groups related form controls or fields and extends the Field component.
The Fieldset component is used to follow the W3C Grouping Controls recommendation for associating related form controls. It renders a <fieldset> element and should always be used in conjunction with the Legend component to provide a title for the group.
This component automatically includes the Field component, so you don't need to worry about wrapping it yourself, just be sure to pass the form and name props to the Fieldset as you would with the Field component.
When to use a fieldset
Radio Groups
When you have a group of radio buttons related to a single field, you should use a Fieldset to group them together.
Checkbox Groups
When you have a group of checkboxes related to a single field, typically used for multiple selections, you should use a Fieldset to group them together.
Grouped Form Sections
When you have a large form with multiple sections containing related fields, such as a "Billing Address" and a "Shipping Address", you should use a <fieldset> to group the related fields together. You won't use the Fieldset component directly in this case, since it doesn't represent a field on the form.
Props
The Fieldset component renders a <fieldset> element and accepts the following props:
Slot Props
The Fieldset component provides a single slot prop, fieldsetAttrs, which is only necessary when using the asChild prop.
Attributes
The following attributes are automatically applied to the <fieldset> element rendered by the Fieldset component. This is also the shape of the fieldsetAttrs slot prop when using the asChild prop.