After installing the packages, four short steps wire BlazorNova into your application: create a config class, register the services, add the init component, and link the generated CSS and JS files.
Create a class that inherits BlazorNovaConfig and set
RelativeOutputDirectory to the project-relative path where the source generator
should write generated files (CSS and JS). This is how the generator knows where to output.
Optionally override LightPalette and DarkPalette to supply
your own brand colours. If you omit these, the default BlazorNova palette is used.
using BlazorNovaGenerator;
public class MyAppConfig : BlazorNovaConfig
{
// Directory is relative to the project root.
// The generator writes generated.css and generated-theme.js here.
public override string RelativeOutputDirectory => "/wwwroot/generated";
// Optional: choose a font preset (default is SystemSans).
// public override BnFontFamily FontFamily => BnFontFamily.Serif;
// Or use a fully custom font stack:
// public override BnFontFamily FontFamily => BnFontFamily.Custom;
// public override string CustomFontFamily => "'Inter', sans-serif";
// Optional: supply your own brand palette.
// public override ThemePalette LightPalette => new MyLightPalette();
// public override ThemePalette DarkPalette => new MyDarkPalette();
}
Create a generated folder inside wwwroot. The source generator
will write generated.css and generated-theme.js into this
directory on every build. The folder must exist before your first build.
# Windows
mkdir wwwroot\generated
# macOS / Linux
mkdir -p wwwroot/generated
Call AddBlazorNova<T>() with your config type. This registers
BlazorNovaConfig, BlazorNovaEngine (theme + popup manager),
and BnJSService (JS interop wrapper) as scoped services.
// Program.cs
builder.Services.AddBlazorNova<MyAppConfig>();
Wrap your Router inside <BlazorNovaInit> in Routes.razor
(Blazor Server) or App.razor (WASM). This component:
prefers-color-scheme changes and re-renders accordinglyBnPopup and modal components use@* Routes.razor (Blazor Server) or App.razor (WASM) *@
<BlazorNovaInit>
<Router AppAssembly="typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="routeData" DefaultLayout="typeof(MainLayout)" />
</Found>
</Router>
</BlazorNovaInit>
Add the generated stylesheet to <head> and the BlazorNova JS
to the end of <body>. If you are using
BlazorNovaComponents, also include its JS file.
<head>
<!-- Generated CSS — updated on every build -->
<link rel="stylesheet" href="generated/generated.css" />
<!-- Theme init — prevents dark-mode flash (also generated on build) -->
<script src="generated/generated-theme.js"></script>
</head>
<body>
<Routes @rendermode="InteractiveServer" />
<script src="_framework/blazor.web.js"></script>
<!-- BlazorNovaUI runtime (theme switching, popups, JS interop) -->
<script src="_content/BlazorNovaUI/BlazorNova.js"></script>
<!-- BlazorNovaComponents runtime (if installed) -->
<script src="_content/BlazorNovaComponents/BnComponents.js"></script>
</body>