Option for adding custom css class for asp-for input tag helper
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
## Background and Motivation
In asp.net core MVC and razor pages, the asp-for tag helper sets a css class for invalid input fields. But there is no way to customize that class name. Most CSS libraries have different class names for validation purposes. So it's important to give a way to change the class name and make asp.net core independent to frontend UI libraries
## Proposed API
```diff
namespace Microsoft.AspNetCore.Mvc.TagHelpers;
[HtmlTargetElement("input", Attributes = ForAttributeName, TagStructure = TagStructure.WithoutEndTag)]
public class InputTagHelper : TagHelper
{
+ [HtmlAttributeName("asp-error-class")]
+ public string ErrorClassName { get; set; }
+ // Changes to Process method to use that ErrorClassName
}
```
## Usage Examples
``` razor
```
## Alternative Designs
It would also be great to have an option to change the default error class name in the application service registration
Contributor guide
Assessment
This issue has not been assessed yet.