Skip to content

Accessibility: FieldSet and Legend component#6464

Merged
stsrki merged 14 commits intomasterfrom
dev/fieldset-legend
Mar 18, 2026
Merged

Accessibility: FieldSet and Legend component#6464
stsrki merged 14 commits intomasterfrom
dev/fieldset-legend

Conversation

@stsrki
Copy link
Copy Markdown
Collaborator

@stsrki stsrki commented Mar 13, 2026

Closes #6441

This PR adds first-class support for semantic form grouping in Blazorise with new independent FieldSet and Legend components. They render native fieldset and legend elements, have dedicated class provider methods across all supported providers, and integrate with existing accessibility options so grouped controls such as RadioGroup can automatically use the parent Legend as their accessible label through aria-labelledby. The PR also adds demo and documentation examples showing the recommended pattern for radio groups and related checkbox sets, while keeping Field and FieldLabel focused on single-input scenarios.

@stsrki stsrki requested a review from njannink March 13, 2026 10:19
@njannink
Copy link
Copy Markdown
Contributor

njannink commented Mar 13, 2026

[x] Code Reviewed

General Test Remarks

  • Was not able to test validation logic. Maybe add to ValidationsPage

Provider Specific Tests

  • AntDesign
    • Alignment for vertical fields off
    image
  • Bootstrap
  • Bootstrap Server
  • Bootstrap5
  • Bulma
    Legend missing and alignments off
    image
  • FluentUI2
  • Material
    • padding / margin of elements is missing
    image
  • Tailwind

Copy link
Copy Markdown
Contributor

@njannink njannink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments in conversation

@stsrki stsrki requested a review from njannink March 13, 2026 22:36
@stsrki
Copy link
Copy Markdown
Collaborator Author

stsrki commented Mar 16, 2026

The latest refactoring moves semantic grouping support onto the existing Field and Fields APIs, instead of treating FieldSet and Legend as specialized versions of Field and FieldLabel. Field and Fields now opt into grouped semantics explicitly, and their label components switch to rendering a legend when used in group mode. At the same time, FieldSet and Legend were simplified into standalone native wrappers that render only the fieldset and legend, without inheriting the behavior, accessibility wiring, or layout assumptions of Field and FieldLabel.

The reason for this split is to avoid forcing native fieldset and legend usage into the styling and behavioral model of a single-field container. A real fieldset can group many different kinds of controls, not just the scenarios that map cleanly to Field, so coupling those components too tightly would artificially limit their use. By reusing Field and Fields for the higher-level grouped API, and keeping FieldSet and Legend as dumb native elements with their own class-provider hooks for horizontal, validation, required-indicator, and screenreader styling, the API becomes clearer: the existing components handle Blazorise form composition, while the standalone wrappers remain available for direct semantic HTML when needed.

@stsrki
Copy link
Copy Markdown
Collaborator Author

stsrki commented Mar 16, 2026

@njannink, please recheck the API and UI

@stsrki
Copy link
Copy Markdown
Collaborator Author

stsrki commented Mar 16, 2026

PS. I'm thinking of renaming the Group parameter to SemanticGroup.

@njannink
Copy link
Copy Markdown
Contributor

SemanticGroup says the same to me as Group. Maybe use (Is)FieldSet to really point at the underlying html that will be rendered?

Copy link
Copy Markdown
Contributor

@njannink njannink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • API Reviewed
  • Documentation tested and reviewed

General Test Remarks

⚠️ Radio groups don't seem to generate the html semantic fieldset tag

Provider Specific Tests

  • AntDesign
  • Bootstrap
  • Bootstrap Server
  • Bootstrap5
  • Bulma
  • FluentUI2
    • legend tag not generated for radio group
  • Material
  • Tailwind

@stsrki stsrki merged commit b9348af into master Mar 18, 2026
1 check passed
@stsrki stsrki deleted the dev/fieldset-legend branch March 18, 2026 09:50
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support fieldset and legend

2 participants