fieldset

Groups related form controls together with an optional caption. Essential for organizing complex forms and providing accessible groupings for screen readers.

When to Use

  • Grouping related form fields (e.g., billing address, shipping address)
  • Radio button or checkbox groups that belong together
  • Sections of a multi-part form
  • Any time you need to provide a group label for accessibility

Always include a legend as the first child to provide a caption for the group.

Basic Usage

A fieldset with a legend creates a visually and semantically grouped form section.

Style Variants

Default (Bordered)

Standard fieldset with a visible border and legend that breaks the border line.

.minimal

Borderless fieldset for subtle grouping. The legend appears as a heading.

Radio Button Groups

Fieldset is essential for grouping radio buttons. Screen readers will announce the legend before each radio option.

Disabled Fieldset

The disabled attribute on a fieldset disables all form controls within it. VB adds a visual treatment: reduced opacity and desaturation so the entire group appears clearly inactive.

Status Variants

Use data-status to apply a subtle border tint indicating the state of the fieldset's contents. Uses the same vocabulary as inline semantics.

Value Border color Use case
success Green-tinted Validated section, completed step
warning Yellow-tinted Needs attention, incomplete
error Red-tinted Validation errors present

Accessibility Notes

  • Always include a legend: The legend provides the accessible name for the group
  • Legend must be first child: For proper rendering, legend must be the first element inside fieldset
  • Screen reader behavior: The legend is announced before each control in the group
  • Required for radio groups: Radio buttons should always be in a fieldset for accessibility
  • Avoid nesting too deep: Limit nesting to maintain comprehension

CSS Reference

Related

  • legend - Caption for the fieldset (required first child)
  • form - Container for fieldsets
  • input - Form controls within fieldsets
  • form-field - Enhanced form field wrapper