https://github.com/iowacomputergurus/aspnetcore.utilities.bootstrap5taghelpers
A collection of Tag Helpers for working with ASP.NET and Bootstrap5
https://github.com/iowacomputergurus/aspnetcore.utilities.bootstrap5taghelpers
Last synced: 11 months ago
JSON representation
A collection of Tag Helpers for working with ASP.NET and Bootstrap5
- Host: GitHub
- URL: https://github.com/iowacomputergurus/aspnetcore.utilities.bootstrap5taghelpers
- Owner: IowaComputerGurus
- License: mit
- Created: 2023-01-03T16:26:44.000Z (over 3 years ago)
- Default Branch: develop
- Last Pushed: 2025-04-28T03:06:07.000Z (about 1 year ago)
- Last Synced: 2025-05-20T06:07:58.886Z (about 1 year ago)
- Language: C#
- Size: 1.18 MB
- Stars: 9
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# AspNetCore Bootstrap5 Tag Helpers 
A collection of TagHelpers for ASP.NET Core that make utilizing the Bootstrap 5.x library easier to use for developers. Designed to reduce code effort substantially

 
[](https://app.codacy.com/gh/IowaComputerGurus/aspnetcore.utilities.bootstrap5taghelpers/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
## Usage Expectations
These tag helpers are only for markup display, your web project must properly include references to Bootstrap and must abide by all license and other requirements of Bootstrap for the functionality to be utilized here. For more on how to include Bootstrap within your project please reference their documentation.
## Setup - Registering TagHelpers
You must modify your `_viewimports.cshtml` file by adding
``` html+razor
@addTagHelper *, ICG.AspNetCore.Utilities.Bootstrap5TagHelpers
```
## Usage
The goal of these tag helpers is to reduce the redundant coding, and compliance with various features of not only the Bootstrap library but form patterns. Within the "Sample" project you will find examples of all tag helper usage. However, the below shows a quick example of the power of these tag helpers.
### Before Bootstrap 5 Tag Helper
The following markup is how you would output a model-bound field for a password field, including a note on complexity and validation.
``` razor
Must be 8 characters with letters & numbers
```
This is a total of *306* characters with spaces or *268* without. Granted we get some help with auto-complete etc.
### After Using Bootstrap 5 Tag Helper
You can take the entire above example and simplify it to the following
``` razor
Must be 8 characters with letters & numbers
```
This is a total of *126* characters with spaces or *112* without. With intellisense, the actual typing characters are much less. Your form view is also substantially reduced, making lines of code per form reduced. For forms without notes the markup improvement is even better.
## Included Tag Helpers
At this time tag helpers have been implemented for the following elements.
| Element | Description of Implementation |
| --- | --- |
| Accordion | Full support for implementation of accordion, including stay-open modes |
| Alerts | Full support for implementation of alerts, including dismissible alerts |
| Badges | Full support for implementation of badges of all Bootstrap color variations |
| Buttons | Full support for implementation of buttons of all Bootstrap color variations, including outlines |
| Cards | Support for Card, Card Header, Card Header Actions, and Card body elements |
| Environment Alert | An extension of the `` tag helper to render as an alert style |
| Input | Support for Form input controls for anything tied to the `` tag including ASP.NET Code Model Binding & Validation |
| Modals | Support for modal dialogs, including Modal Body, header, footer, dismiss, and toggles |
| Offcanvas | Full support for implementation of offcanvas display, including sizing/placement |
| TextArea | Support for Form input controls tied to the `` tag including ASP.NET Core Model Binding & Validation |
If you find that we are missing a particular tag helper, we welcome contributions!
## Special Features
The tag helpers automatically inspect form elements and add a "required" css class in addition to the `form-label` class default allowing for indication of required fields easily with CSS such as the following.
```` css
label.required:after {
content: " *";
color: red;
}
````