Skip to content

feat(blazor): add CssClass parameter to ValidationSummary component#66531

Open
EduardF1 wants to merge 4 commits intodotnet:mainfrom
EduardF1:feat/validationsummary-cssclass
Open

feat(blazor): add CssClass parameter to ValidationSummary component#66531
EduardF1 wants to merge 4 commits intodotnet:mainfrom
EduardF1:feat/validationsummary-cssclass

Conversation

@EduardF1
Copy link
Copy Markdown

Summary

Fixes #43860

Adds a CssClass parameter to the ValidationSummary Blazor component so users can pass custom CSS classes that get appended to the default validation-errors class.

Before:

<ValidationSummary class="pt-2" />
<!-- renders: class="validation-errors"  (class attribute ignored) -->

After:

<ValidationSummary CssClass="pt-2" />
<!-- renders: class="validation-errors pt-2" -->

Implementation

Implements the approach suggested by @SteveSandersonMS in the issue comments. Adds a CssClass parameter following the same pattern used by InputBase<T> and other Blazor form components:

  • AttributeUtilities.CombineClassNames merges AdditionalAttributes["class"] (if any), the base validation-errors class, and the new CssClass parameter
  • The render tree order is swapped: AddMultipleAttributes fires first, then AddAttribute for class so the computed combined class correctly overrides any class key that might exist in AdditionalAttributes

Changes

  • src/Components/Web/src/Forms/ValidationSummary.cs — adds CssClass parameter and updates BuildRenderTree
  • src/Components/Web/src/PublicAPI.Unshipped.txt — new public API entries
  • src/Components/test/testassets/BasicTestApp/FormsTest/TypicalValidationComponent.razor — adds a second <ValidationSummary CssClass="custom-summary-css-class" /> for E2E coverage
  • src/Components/test/E2ETest/Tests/FormsTest.cs — adds ValidationSummaryAppliesCssClass E2E test

@EduardF1 EduardF1 requested a review from a team as a code owner April 29, 2026 22:14
@github-actions github-actions Bot added the area-blazor Includes: Blazor, Razor Components label Apr 29, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Apr 29, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Thanks for your PR, @EduardF1. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@EduardF1
Copy link
Copy Markdown
Author

@dotnet-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass css class in <ValidationSummary /> to the generated <ul>

1 participant