# HAVIT Blazor Bootstrap Component Library HAVIT Blazor is a comprehensive, free Bootstrap 5.3 component library for ASP.NET Blazor applications. It provides a rich set of UI components including form inputs, data grids, modals, navigation elements, and more - all designed to integrate seamlessly with Blazor's component model. The library supports both Blazor Server and Blazor WebAssembly hosting models, with features like cascading parameters, two-way binding, and async event handling. The library follows Bootstrap's design patterns while adding enterprise-ready features such as built-in validation support, customizable defaults through static settings, and extensive parameter configuration. Components are prefixed with "Hx" (e.g., HxButton, HxGrid, HxModal) and support both simple usage scenarios and advanced customization through settings objects, templates, and CSS class parameters. --- ## HxButton Bootstrap button component with support for icons, spinners, tooltips, and form validation integration. Automatically shows a spinner during async click handlers and provides single-click protection. ```razor @* Basic button with click handler *@ @* Button with icon and outline style *@ @* Button with spinner during async operation *@ @* Button with tooltip *@ @* Form submit button with validation *@ @code { private async Task HandleClick() => await Task.CompletedTask; private async Task SaveAsync() => await Task.Delay(1000); private async Task HandleValidClick(MouseEventArgs args) => await SaveDataAsync(); private async Task HandleInvalidClick(MouseEventArgs args) => ShowValidationErrors(); } ``` --- ## HxGrid Data grid component for displaying tabular data with support for client-side and server-side paging, sorting, selection, and infinite scrolling. ```razor @* Basic grid with columns and data provider *@ @* Grid with selection and custom row styling *@ @(employee.IsActive ? "Active" : "Inactive") @* Grid with multi-selection *@ @code { private Employee selectedEmployee; private HashSet selectedEmployees = new(); private async Task> LoadEmployees(GridDataProviderRequest request) { // Server-side implementation with paging and sorting var query = dbContext.Employees.AsQueryable(); // Apply sorting from request foreach (var sorting in request.Sorting ?? Enumerable.Empty>()) { query = sorting.SortDirection == SortDirection.Ascending ? query.OrderBy(sorting.SortKeySelector) : query.OrderByDescending(sorting.SortKeySelector); } var totalCount = await query.CountAsync(); var data = await query .Skip(request.StartIndex) .Take(request.Count ?? 10) .ToListAsync(request.CancellationToken); return new GridDataProviderResult { Data = data, TotalCount = totalCount }; } public class Employee { public int Id { get; set; } public string Name { get; set; } public string Email { get; set; } public string Department { get; set; } public decimal Salary { get; set; } public bool IsActive { get; set; } } } ``` --- ## HxModal Bootstrap modal dialog component with support for headers, bodies, footers, sizing, and programmatic show/hide control. ```razor @* Basic modal with title and body *@

Are you sure you want to proceed?

@* Large centered modal with custom header *@
@* Long content that requires scrolling *@
@* Modal with static backdrop (cannot close by clicking outside) *@ @code { private HxModal modal; private HxModal detailModal; private HxModal editModal; private EditModel editModel = new(); private async Task HandleConfirm() { await ProcessConfirmation(); await modal.HideAsync(); } private void HandleModalClosed() => Console.WriteLine("Modal closed"); private void HandleModalHiding(ModalHidingEventArgs args) { // Cancel closing if form has unsaved changes if (HasUnsavedChanges()) { args.Cancel = true; } } } ``` --- ## HxOffcanvas Bootstrap offcanvas (drawer) component for side panels, typically used for navigation menus or detail views. ```razor @* Basic offcanvas from the right *@ @* Large offcanvas from the left with custom size *@ @code { private HxOffcanvas offcanvas; private HxOffcanvas filterOffcanvas; private SettingsModel settings = new(); private FilterModel filter = new(); private List categories = new() { "All", "Active", "Archived" }; private async Task SaveSettings() { await SaveSettingsToDb(); await offcanvas.HideAsync(); } } ``` --- ## HxInputText Text input component with Bootstrap styling, label support, floating labels, and validation integration. ```razor @* Basic text input with label *@ @* Password input *@ @* Email input with placeholder *@ @* Input with floating label *@ @* Input with input groups *@ @* Input with validation and hint *@ @code { private FormModel model = new(); public class FormModel { [Required] [StringLength(100)] public string Name { get; set; } [Required] [EmailAddress] public string Email { get; set; } public string Username { get; set; } public string Password { get; set; } public string Website { get; set; } [Phone] public string Phone { get; set; } } } ``` --- ## HxSelect Dropdown select component for single-item selection from a list of options. ```razor @* Basic select with enum values *@ @* Select with custom object data *@ @* Select with disabled items *@ @code { private Priority selectedPriority; private int selectedCountryId; private int selectedProductId; private List countries = new() { new() { Id = 1, Name = "United States" }, new() { Id = 2, Name = "Canada" }, new() { Id = 3, Name = "United Kingdom" } }; private List products = new() { new() { Id = 1, Name = "Widget A", InStock = true }, new() { Id = 2, Name = "Widget B", InStock = false } }; public enum Priority { Low, Medium, High, Critical } public class Country { public int Id; public string Name; } public class Product { public int Id; public string Name; public bool InStock; } } ``` --- ## HxAutosuggest Autocomplete/typeahead input component with dynamic suggestions based on user input. ```razor @* Basic autosuggest with data provider *@ @* Autosuggest with custom item template *@
@user.DisplayName @user.Email
No users found
@code { private int selectedCityId; private int selectedUserId; private async Task> SearchCities(AutosuggestDataProviderRequest request) { var cities = await dbContext.Cities .Where(c => c.Name.Contains(request.UserInput)) .Take(10) .ToListAsync(request.CancellationToken); return new AutosuggestDataProviderResult { Data = cities }; } private async Task GetCityById(int cityId) { return await dbContext.Cities.FindAsync(cityId); } private async Task> SearchUsers(AutosuggestDataProviderRequest request) { var users = await userService.SearchAsync(request.UserInput, request.CancellationToken); return new AutosuggestDataProviderResult { Data = users }; } private async Task GetUserById(int userId) => await userService.GetByIdAsync(userId); public class City { public int Id; public string Name; } public class User { public int Id; public string DisplayName; public string Email; public string AvatarUrl; } } ``` --- ## HxMessenger Toast notification service for displaying temporary messages to users. Requires `HxMessenger` component in layout and `IHxMessengerService` injection. ```razor @* In MainLayout.razor or App.razor *@ @* In a page or component *@ @inject IHxMessengerService Messenger @code { private void ShowSuccess() { Messenger.AddInformation("Record saved successfully!"); } private void ShowError() { Messenger.AddError("Failed to save record. Please try again."); } private void ShowInfo() { Messenger.AddMessage(new MessengerMessage { Title = "Notification", Text = "You have 3 new messages", Color = ThemeColor.Primary, AutohideDelay = 5000 // 5 seconds }); } } ``` --- ## HxSidebar Responsive navigation sidebar component with collapsible items and mobile support. ```razor Logo My App
@if (!context.SidebarCollapsed) { Logged in as @userName }
@code { private bool sidebarCollapsed = false; private string userName = "John Doe"; } ``` --- ## HxAlert Bootstrap alert component for displaying contextual feedback messages. ```razor @* Basic alerts *@ Record saved successfully! An error occurred while processing your request. Please review your input before submitting. System maintenance scheduled for tonight. @* Dismissible alert *@ New feature! Check out our latest update. @* Alert with icon *@ Error: Unable to connect to the server. @code { private void HandleDismissed() => Console.WriteLine("Alert dismissed"); } ``` --- ## HxTabPanel Tab navigation component for organizing content into switchable panels. ```razor Settings

Advanced configuration options...

@code { private Model model = new(); private bool showAdvanced = true; private List categories = new() { "A", "B", "C" }; public class Model { public string Name { get; set; } public string Description { get; set; } public bool IsActive { get; set; } public string Category { get; set; } } } ``` --- ## HxAccordion Bootstrap accordion component for displaying collapsible content panels. ```razor

Content for the first section. This is expanded by default.

Content for the second section.

FAQ

Frequently asked questions content...

``` --- ## Service Registration Register HAVIT Blazor services in your application's startup configuration. ```csharp // Program.cs using Havit.Blazor.Components.Web; using Havit.Blazor.Components.Web.Bootstrap; var builder = WebApplication.CreateBuilder(args); // Add HAVIT Blazor services builder.Services.AddHxServices(); builder.Services.AddHxMessenger(); builder.Services.AddHxMessageBoxHost(); // Configure global defaults (optional) HxButton.Defaults.Color = ThemeColor.Primary; HxButton.Defaults.Size = ButtonSize.Regular; HxGrid.Defaults.PageSize = 20; HxGrid.Defaults.Striped = true; HxModal.Defaults.Centered = true; HxInputText.Defaults.LabelType = LabelType.Floating; var app = builder.Build(); ``` --- ## CSS and JavaScript Setup Include the required CSS and JavaScript files in your application. ```html ``` --- HAVIT Blazor is designed for building enterprise-grade Blazor applications with a consistent, professional look and feel. The components integrate naturally with Blazor's component model, supporting two-way binding, cascading parameters, and EditForm validation. Common use cases include admin dashboards, data management interfaces, CRUD applications, and internal business tools where Bootstrap styling and responsive design are required. The library follows a consistent pattern where each component has static `Defaults` that can be configured application-wide, instance-level `Settings` for shared configurations, and individual parameters for component-specific customization. This three-tier configuration approach allows for maximum flexibility while maintaining consistency across an application. Components also support extensive CSS customization through `CssClass` parameters and follow Bootstrap's utility class conventions for spacing, sizing, and responsiveness.