Blazorify.Bootstrap 1.0.0-preview.251224172625

This is a prerelease version of Blazorify.Bootstrap.
dotnet add package Blazorify.Bootstrap --version 1.0.0-preview.251224172625
                    
NuGet\Install-Package Blazorify.Bootstrap -Version 1.0.0-preview.251224172625
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Blazorify.Bootstrap" Version="1.0.0-preview.251224172625" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Blazorify.Bootstrap" Version="1.0.0-preview.251224172625" />
                    
Directory.Packages.props
<PackageReference Include="Blazorify.Bootstrap" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Blazorify.Bootstrap --version 1.0.0-preview.251224172625
                    
#r "nuget: Blazorify.Bootstrap, 1.0.0-preview.251224172625"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Blazorify.Bootstrap@1.0.0-preview.251224172625
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Blazorify.Bootstrap&version=1.0.0-preview.251224172625&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Blazorify.Bootstrap&version=1.0.0-preview.251224172625&prerelease
                    
Install as a Cake Tool

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}.css compiled with Dart Sass.
  • A bundled helper script at /_blazorify/bootstrap/scripts.js.
  • 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;
}

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.scss entry under the provided namespace. All .scss resources are extracted to a temp folder and compiled with Dart Sass (powered by the Blazorify.Sass package).

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.