Blazorify.Bootstrap
1.1.0
dotnet add package Blazorify.Bootstrap --version 1.1.0
NuGet\Install-Package Blazorify.Bootstrap -Version 1.1.0
<PackageReference Include="Blazorify.Bootstrap" Version="1.1.0" />
<PackageVersion Include="Blazorify.Bootstrap" Version="1.1.0" />
<PackageReference Include="Blazorify.Bootstrap" />
paket add Blazorify.Bootstrap --version 1.1.0
#r "nuget: Blazorify.Bootstrap, 1.1.0"
#:package Blazorify.Bootstrap@1.1.0
#addin nuget:?package=Blazorify.Bootstrap&version=1.1.0
#tool nuget:?package=Blazorify.Bootstrap&version=1.1.0
Blazorify.Bootstrap
Bootstrap-powered components for Blazor with runtime Sass compilation (via Blazorify.Sass) and zero external tooling.
What you get
- Bootstrap-styled components (
BuiButton,BuiModal,BuiToast, etc.). - On-demand CSS per theme at
/_blazorify/bootstrap/{theme}.csscompiled with Dart Sass. - A bundled helper script at
/_blazorify/bootstrap/scripts.js. - Light / dark / auto color modes: a no-flash startup script,
BuiThemeService,BuiThemeToggle, and aThemeparameter on every component. - Simple DI and middleware extensions to plug everything into your app.
Quick start
Install the package:
dotnet add package Blazorify.Bootstrap
Add the namespace (e.g., _Imports.razor):
@using Blazorify.Bootstrap
Register services and middleware (Program.cs):
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddBlazorify(); // components + Sass + resources
var app = builder.Build();
app.UseStaticFiles();
app.UseRouting();
app.UseBlazorify(); // exposes CSS + JS endpoints
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
app.Run();
Include the assets (e.g., in _Host.cshtml or wwwroot/index.html):
<link rel="stylesheet" href="/_blazorify/bootstrap/bootstrap.css" />
<script src="/_blazorify/bootstrap/scripts.js"></script>
Use components:
<BuiButton Variant="Variant.Primary">Click me</BuiButton>
Toasts (container + service):
@inject BuiToastService Toasts
<BuiToastContainer Placement="Placement.TopEnd" />
<BuiButton Variant="Variant.Secondary" @onclick="Notify">Show toast</BuiButton>
@code {
private Task Notify() => Toasts.Success("Saved!");
}
Modals (provider + service):
@inject BuiModalService Modals
<BuiModalProvider />
<BuiButton Variant="Variant.Primary" @onclick="OpenModal">Open modal</BuiButton>
@code {
private Task OpenModal() => Modals.Show<SampleModal>(opts => {
opts.Centered = true;
opts.Size = Size.Large;
opts.Data<SampleModal>(c => c.Message, "Hello from modal");
});
}
SampleModal.razor (example modal content component):
@namespace YourApp.Components
@inherits BuiContentComponentBase
<BuiModalHeader>
<h5 class="modal-title">Sample modal</h5>
</BuiModalHeader>
<BuiModalBody>
<p>@Message</p>
</BuiModalBody>
<BuiModalFooter>
<BuiButton Variant="Variant.Primary" @onclick="Close">Close</BuiButton>
</BuiModalFooter>
@code {
[CascadingParameter] public BuiModal? Modal { get; set; }
[Parameter] public String? Message { get; set; }
private Task Close() => this.Modal?.Close() ?? Task.CompletedTask;
}
Color modes (light / dark / auto)
Bootstrap 5.3 color modes are built in, modeled on the color mode toggler from the Bootstrap docs. The chosen mode is stored in localStorage (key theme) and applied as data-bs-theme on <html>; auto follows the operating system and updates live when it changes.
Load the startup script as a blocking script in <head>, before any stylesheet that should follow the mode, so the page is painted in the right mode without a flash:
<script src="/_blazorify/bootstrap/color-mode.js"></script>
Without a stored choice the mode is auto; set another default with data-default-mode="light" (or dark) on that tag.
Drop in the toggle (a dropdown with Light / Dark / Auto, using Bootstrap Icons names):
<BuiThemeToggle />
<BuiThemeToggle Dropdown="false" IncludeAuto="false" Variant="Variant.Link" /> @* single light/dark button *@
Parameters: Dropdown, IncludeAuto, Variant, Size, Caret, MenuPlacement, Label / ShowLabel, LightLabel / DarkLabel / AutoLabel, LightIcon / DarkIcon / AutoIcon, OnChange.
Or drive it from code with BuiThemeService (registered by AddBlazorify(); call it after the first render):
@inject BuiThemeService ThemeService
@code {
protected override async Task OnAfterRenderAsync(bool firstRender) {
if (firstRender) {
var mode = await ThemeService.GetModeAsync(); // Light, Dark or Auto
var shown = await ThemeService.GetThemeAsync(); // Light or Dark, with Auto resolved
}
}
private Task UseDark() => ThemeService.SetModeAsync(ColorMode.Dark);
}
ThemeService.Changed fires when the mode changes, including from another browser tab.
Every component also takes a Theme parameter for a color mode on just that part of the page (rendered as data-bs-theme):
<BuiNavbar Theme="ColorMode.Dark">...</BuiNavbar>
<BuiDropdownMenu Theme="ColorMode.Dark">...</BuiDropdownMenu>
Custom themes
Themes are compiled from embedded .scss files. The default bootstrap theme ships in this package with an index.scss entry point under Blazorify.Bootstrap.Resources.
Register your own theme (SCSS embedded in another assembly):
builder.Services.AddBlazorify(options => {
options.Themes["mytheme"] = new() {
Assembly = typeof(MyThemeMarker).Assembly, // any type from your theme assembly
Namespace = "MyCompany.MyTheme.Resources" // prefix for embedded SCSS resources
};
});
Request it at:
<link rel="stylesheet" href="/_blazorify/bootstrap/mytheme.css" />
Each theme needs an
index.scssentry under the provided namespace. All.scssresources are extracted to a temp folder and compiled with Dart Sass (powered by theBlazorify.Sasspackage).
Scripts endpoint
/_blazorify/bootstrap/scripts.js delivers helper JS for certain components (modals, file drop, etc.). Include it once per page before </body>.
Contributing
Issues and PRs are welcome. Please keep changes focused and describe the scenario your contribution improves.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Blazorify.Sass (>= 1.0.0-preview.251223204523)
- Microsoft.AspNetCore.Components (>= 10.0.0)
- Microsoft.AspNetCore.Components.Web (>= 10.0.0)
- Microsoft.AspNetCore.Mvc.ViewFeatures (>= 2.2.0)
- Microsoft.JSInterop (>= 10.0.0)
- Newtonsoft.Json (>= 13.0.3)
- System.Security.Cryptography.Xml (>= 10.0.13)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.0 | 72 | 11/7/2026 |
| 1.0.0-preview.251228105153 | 133 | 12/28/2025 |
| 1.0.0-preview.251224172625 | 183 | 12/24/2025 |
| 1.0.0-preview.251224162048 | 187 | 12/24/2025 |
| 1.0.0-preview.250629064338 | 159 | 6/29/2025 |
| 1.0.0-preview.250316080253 | 424 | 3/16/2025 |
| 1.0.0-preview.250316075848 | 215 | 3/16/2025 |
| 1.0.0-preview.250316074054 | 220 | 3/16/2025 |
| 1.0.0-preview.250316073640 | 197 | 3/16/2025 |
| 1.0.0-preview.250304171247 | 318 | 3/4/2025 |
| 1.0.0-preview.250226074835 | 158 | 2/26/2025 |
| 1.0.0-preview.250226074659 | 145 | 2/26/2025 |
| 1.0.0-preview.250219152311 | 168 | 2/19/2025 |
| 1.0.0-preview.250219141343 | 161 | 2/19/2025 |
| 1.0.0-preview.250211003935 | 202 | 2/11/2025 |
| 1.0.0-preview.250208104849 | 212 | 2/8/2025 |
| 1.0.0-preview.250208070719 | 157 | 2/8/2025 |
| 1.0.0-preview.250203103148 | 196 | 2/3/2025 |
| 1.0.0-preview.250203100641 | 178 | 2/3/2025 |
| 1.0.0-preview.250201172120 | 168 | 2/1/2025 |