Blazor playground

Nova v3.38.0

Preview

Blazor

Installation

Install Nova, configure Tailwind CSS and themes, and render your first component.

dotnet add package Nova.Design.System.Blazor
  • .NET runtime 8.0.33, 9.0.22, or 10.0.14 or later in the same major
  • NuGet package
  • 6 steps to your first component

New to Nova? Read Getting Started

Install Nova in a Blazor application, enable the built-in Tailwind CSS v4 compiler, wire up your host file, and render your first strongly typed Nv* component.

Requirements#

RequirementMinimum version
.NET runtime8.0.33, 9.0.22, or 10.0.14 or later in the same major (Nova.Design.System.Blazor multi-targets net8.0 and net10.0)
Node.js (optional)Only required for existing projects keeping the legacy npm Tailwind CLI workflow
No Node.js required

Nova.Design.System.Blazor embeds a pure-managed .NET Tailwind CSS v4 compiler alongside Nova's CSS-first plugin and the Spark and Ocean themes. New Blazor projects do not need Node.js, npm, or @nova-design-system/nova-base.

1. Install the NuGet package#

Add Nova.Design.System.Blazor to your Blazor project:

bashdotnet add package Nova.Design.System.Blazor

Or add the reference directly in your .csproj file:

xml<PackageReference Include="Nova.Design.System.Blazor" Version="x.y.z" />

2. Set up Tailwind CSS and themes#

Nova uses Tailwind CSS v4 for layout, spacing, and token-driven styling.

For any Blazor project without a Node.js Tailwind CLI setup (no package.json in the project folder or the folder above it, and no Styles/tailwind.css), build-time compilation to wwwroot/css/tailwind.css activates automatically on dotnet build, dotnet publish, and Visual Studio builds. It never overwrites a tailwind.css it did not generate.

For Blazor Web App (.NET 8+) and Blazor Server projects, enable live CSS hot reload in Program.cs:

csharpvar builder = WebApplication.CreateBuilder(args);
// ...
builder.AddNovaTailwind(); // Theme and paths come from your .csproj

var app = builder.Build();

app.UseNovaTailwind(); // Live CSS hot reload in Development (F5 & dotnet watch); no-op in Production
app.UseStaticFiles();
Standalone Blazor WebAssembly

Omit AddNovaTailwind() and UseNovaTailwind() in standalone WebAssembly apps — there is no ASP.NET Core server host. MSBuild still compiles wwwroot/css/tailwind.css automatically on build and publish.

By default, Nova uses the Spark theme, imports Styles/app.css when present, and writes wwwroot/css/tailwind.css. Override any setting in your .csproj:

xml<PropertyGroup>
  <!-- Spark (default) or Ocean -->
  <NovaTailwindTheme>Ocean</NovaTailwindTheme>
  <NovaTailwindInputCss>Styles/app.css</NovaTailwindInputCss>
  <NovaTailwindOutputCss>wwwroot/css/tailwind.css</NovaTailwindOutputCss>
  <NovaTailwindAdditionalScanDirectories>..\MySharedRcl</NovaTailwindAdditionalScanDirectories>
</PropertyGroup>

For full Tailwind configuration options, custom @apply stylesheets, and migrating off an existing npm Tailwind CLI setup, see Tailwind Setup.

Alternative: existing projects using Node.js and the npm Tailwind CLI

Existing projects that already contain a package.json or Styles/tailwind.css keep the npm Tailwind CLI pipeline active automatically. Keep your NuGet (Nova.Design.System.Blazor) and npm (@nova-design-system/nova-base) versions aligned — the build warns when they diverge.

Install Tailwind and @nova-design-system/nova-base next to your .csproj:

bashnpm init -y
npm install tailwindcss @tailwindcss/cli @nova-design-system/nova-base@<version>

On Elia virtual machines with SSL proxy issues, run npm config set strict-ssl false before installing.

Configure Styles/tailwind.css with Tailwind v4, Nova's CSS-only plugin, and exactly one theme:

css@import 'tailwindcss';
@import '@nova-design-system/nova-base/theme/plugin.css';
@import '@nova-design-system/nova-base/dist/css/spark.css';
/* Or import ocean.css instead of spark.css. */

Add an MSBuild target to .csproj so builds compile wwwroot/css/tailwind.css:

xml<Target Name="BuildTailwindCSS" BeforeTargets="Build">
  <Exec Command="npx @tailwindcss/cli -i ./Styles/tailwind.css -o ./wwwroot/css/tailwind.css" />
</Target>

See Tailwind Setup for explicit @source scanning, dotnet watch hooks, and the deprecated JavaScript Tailwind config.

3. Wire up your host file#

Nova's stylesheet, scripts, and font link belong in your application's host file:

Project typeHost fileBlazor script
Blazor Web App (.NET 8+, Server and/or WASM)Components/App.razor_framework/blazor.web.js
Blazor WebAssembly (standalone)wwwroot/index.html_framework/blazor.webassembly.js
Blazor Server (.NET 6/7, legacy)Pages/_Host.cshtml_framework/blazor.server.js

Add these tags inside <head>:

html<!-- Compiled Tailwind stylesheet (already includes the selected Spark or Ocean theme) -->
<link rel="stylesheet" href="css/tailwind.css" />
<!-- Nova Font Pro (see Add Nova Font Pro below) -->
<link rel="stylesheet" href="contact-us-for-URL/nova-fonts-pro.css" />
<!-- Nova web components and Blazor interop helper -->
<script type="module" src="_content/Nova.Design.System.Blazor/nova/native.esm.js"></script>
<script src="_content/Nova.Design.System.Blazor/js/helper.js"></script>

Use helper.min.js instead of helper.js in production.

Ordering rules#

  • Keep both Nova <script> tags in <head>, and keep type="module" on native.esm.js.
  • Do not add defer to helper.js and do not place it after blazor.*.js — helper.js registers window interop functions that must exist before Blazor starts.
  • Keep blazor.*.js last, at the end of <body>.
  • Load css/tailwind.css after your own base stylesheet.
  • Do not also link nova.css or nova-utils.css — the compiled Tailwind stylesheet already bundles the selected theme.

Dark mode#

Toggle dark mode by adding the dark class to <body> (or another root element):

html<body class="dark">
Complete host file examples (App.razor, index.html, _Host.cshtml)

Blazor Web App (.NET 8+) — Components/App.razor:

razor<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <base href="/" />

    <link rel="stylesheet" href="app.css" />
    <link rel="icon" type="image/png" href="favicon.png" />

    <link rel="stylesheet" href="css/tailwind.css" />
    <link rel="stylesheet" href="contact-us-for-URL/nova-fonts-pro.css" />
    <script type="module" src="_content/Nova.Design.System.Blazor/nova/native.esm.js"></script>
    <script src="_content/Nova.Design.System.Blazor/js/helper.js"></script>

    <HeadOutlet @rendermode="InteractiveServer" />
</head>

<body>
    <Routes @rendermode="InteractiveServer" />

    <div id="blazor-error-ui">
        An unhandled error has occurred.
        <a href="." class="reload">Reload</a>
        <span class="dismiss">🗙</span>
    </div>

    <script src="_framework/blazor.web.js"></script>
</body>

</html>

Blazor WebAssembly (standalone) — wwwroot/index.html:

html<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>My Nova App</title>
    <base href="/" />

    <link rel="stylesheet" href="css/app.css" />
    <link rel="icon" type="image/png" href="favicon.png" />

    <link rel="stylesheet" href="css/tailwind.css" />
    <link rel="stylesheet" href="contact-us-for-URL/nova-fonts-pro.css" />
    <script type="module" src="_content/Nova.Design.System.Blazor/nova/native.esm.js"></script>
    <script src="_content/Nova.Design.System.Blazor/js/helper.js"></script>
</head>

<body>
    <div id="app">Loading...</div>

    <div id="blazor-error-ui">
        An unhandled error has occurred.
        <a href="." class="reload">Reload</a>
        <span class="dismiss">🗙</span>
    </div>

    <script src="_framework/blazor.webassembly.js"></script>
</body>

</html>

Blazor Server (.NET 6/7) — Pages/_Host.cshtml:

cshtml@page "/"
@namespace MyApp.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
    Layout = null;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <base href="~/" />

    <link rel="stylesheet" href="css/site.css" />
    <link rel="stylesheet" href="css/tailwind.css" />
    <link rel="stylesheet" href="contact-us-for-URL/nova-fonts-pro.css" />
    <script type="module" src="_content/Nova.Design.System.Blazor/nova/native.esm.js"></script>
    <script src="_content/Nova.Design.System.Blazor/js/helper.js"></script>

    <component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
</head>

<body>
    <component type="typeof(App)" render-mode="ServerPrerendered" />

    <div id="blazor-error-ui">
        An unhandled error has occurred.
        <a href="" class="reload">Reload</a>
        <a class="dismiss">🗙</a>
    </div>

    <script src="_framework/blazor.server.js"></script>
</body>

</html>

4. Import the Nova namespaces#

Add the Nova namespaces to _Imports.razor so every Razor file can use Nv* components and their models without per-file @using directives:

razor@using NovaComponents
@using NovaComponents.Models

5. Add Nova Font Pro#

Protected asset

Nova Font Pro (TT Norms Pro) is a licensed Elia Group asset and is not bundled in the package. Get the stylesheet URL from the Nova internal wiki or ask the Nova team on Teams.

Link the font stylesheet in your host file (recommended):

html<link rel="stylesheet" href="contact-us-for-URL/nova-fonts-pro.css" />

Or import it in your global stylesheet (Styles/app.css or Styles/tailwind.css):

css@import url('contact-us-for-URL/nova-fonts-pro.css');

6. Render your first component#

Nova Blazor components are strongly typed with nested enums (such as NvButton.EmphasisEnum.high), standard @onclick / EventCallback events, and @bind-Value / @bind-Checked two-way binding.

razor@page "/example"

<div class="flex max-w-md flex-col gap-4 p-6">
    <NvFieldtext Label="Name" Placeholder="Enter your name" @bind-Value="name" />

    <NvButton Emphasis="NvButton.EmphasisEnum.high" @onclick="Greet">
        Say hello
    </NvButton>

    @if (!string.IsNullOrWhiteSpace(greeting))
    {
        <NvAlert Feedback="NvAlert.FeedbackEnum.information" Heading="@greeting" />
    }
</div>

@code {
    private string name = "";
    private string? greeting;

    private void Greet()
    {
        greeting = string.IsNullOrWhiteSpace(name) ? "Hello from Nova." : $"Hello, {name}.";
    }
}

Working with slots#

Blazor exposes component slots as typed RenderFragment parameters suffixed with Slot (for example LeadingIconSlot, TrailingIconSlot, TriggerSlot, or HeaderSlot). When combining named slot fragments with default content, place the default content inside <ChildContent>:

razor<NvButton Emphasis="NvButton.EmphasisEnum.medium">
    <LeadingIconSlot>
        <NvIcon Name="NvIcon.NameEnum.download" aria-hidden="true" />
    </LeadingIconSlot>
    <ChildContent>Export report</ChildContent>
    <TrailingIconSlot>
        <NvIcon Name="NvIcon.NameEnum.arrowright" aria-hidden="true" />
    </TrailingIconSlot>
</NvButton>

Slot content can be added, removed, and reordered dynamically after the first render without remounting the parent component.

Troubleshooting#

SymptomWhat to check
Components are not recognised in .razor filesAdd @using NovaComponents and @using NovaComponents.Models to _Imports.razor.
Components render unstyledConfirm <link rel="stylesheet" href="css/tailwind.css" /> is in your host file and nova.css / nova-utils.css are not linked alongside it.
Interactive components do not respondConfirm native.esm.js keeps type="module", helper.js loads without defer before blazor.*.js, and the page has an interactive render mode.
Version mismatch warning on buildOnly applies to the legacy npm CLI setup: align @nova-design-system/nova-base in package.json with your Nova.Design.System.Blazor NuGet version and run npm install.
Live CSS does not reload on Visual Studio F5Confirm both builder.AddNovaTailwind() and app.UseNovaTailwind() are called in Program.cs (with UseNovaTailwind() before UseStaticFiles()), and ASPNETCORE_ENVIRONMENT is Development.

Next steps#