Jazor.Css 0.1.31

There is a newer version of this package available.
See the version list below for details.
dotnet add package Jazor.Css --version 0.1.31
                    
NuGet\Install-Package Jazor.Css -Version 0.1.31
                    
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="Jazor.Css" Version="0.1.31" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Jazor.Css" Version="0.1.31" />
                    
Directory.Packages.props
<PackageReference Include="Jazor.Css" />
                    
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 Jazor.Css --version 0.1.31
                    
#r "nuget: Jazor.Css, 0.1.31"
                    
#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 Jazor.Css@0.1.31
                    
#: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=Jazor.Css&version=0.1.31
                    
Install as a Cake Addin
#tool nuget:?package=Jazor.Css&version=0.1.31
                    
Install as a Cake Tool

Jazor.Css

Deterministic CSS-in-JS authoring for Jazor applications.

Jazor.Css is an independent, framework-neutral package. It compiles structured C# style declarations into the standard Jazor.Css/runtime.mjs module, generates stable names from normalized content, and manages one owned browser stylesheet. The return value of Css.Class is an ordinary string, so plain ECMAScript modules, direct Vue authoring, and RazorVue components consume it without an adapter.

Install

<ItemGroup>
  <PackageReference Include="Jazor.Css" Version="0.1.31" />
</ItemGroup>

The package depends on the exact same version of Jazor. It does not install a Razor Hook, Vue integration, or CSS-specific MSBuild targets.

Class Rules

using Jazor.Css;

var buttonClass = Css.Class(new CssRule
{
    Display = "inline-flex",
    AlignItems = "center",
    Gap = "0.5rem",
    Color = "white",
    BackgroundColor = "#1769aa",
    ["--button-shadow"] = "0 0.25rem 0.75rem rgb(0 0 0 / 18%)",
    Children =
    [
        new(CssChildKind.Selector, "&:hover, &:focus-visible", new CssRule
        {
            BackgroundColor = "#125486"
        }),
        new(CssChildKind.Media, "(width < 40rem)", new CssRule
        {
            Width = "100%"
        })
    ]
});

Standard declarations are generated from the repository Webref inventory. The indexer accepts custom properties and other valid declaration names. Use Additional when duplicate declarations or fallback order are semantically significant:

var layoutClass = Css.Class(new CssRule
{
    Additional =
    [
        new("display", "-webkit-box"),
        new("display", "flex", Important: true)
    ]
});

Named properties are normalized by CSS name, independent of C# initializer order. Children and Additional preserve author order because order is observable in the cascade.

Keyframes And Global Rules

var fadeIn = Css.Keyframes(
    new("from", new CssDeclarations { Opacity = "0" }),
    new("to", new CssDeclarations { Opacity = "1" }));

Css.Global("html, body", new CssRule
{
    Margin = "0",
    MinHeight = "100%"
});

Css.Keyframes returns a deterministic animation name. Css.Global registers a selector rule and deduplicates identical content. The first phase supports selector children, @media, and @supports; it does not accept arbitrary raw CSS or other at-rules.

Browser Configuration

Css.Configure(new CssOptions
{
    StyleId = "application-styles",
    Nonce = cspNonce
});

Call Css.Configure before the first class, keyframe, or global registration. In a browser, the runtime creates or adopts one marked <style> element, validates its ownership and nonce, and uses length-delimited entries to remain idempotent across module reloads. Without a DOM, registration and extraction continue in memory.

Css.Extract() returns the current CSS text without clearing the registry. It is suitable for diagnostics and controlled rendering flows, but the first phase does not provide per-request SSR isolation.

Build Output

Jazor.Css uses the standard Jazor output contract without additional properties:

  • JazorMode=none writes no artifacts.
  • JazorMode=debug materializes Jazor.Css/runtime.mjs, its source map, and the manifest entry.
  • JazorMode=release includes the runtime and its consumers in bundle.js.

Release mode remains runtime CSS-in-JS. It does not emit a separate .css file or perform build-time extraction, PostCSS processing, prefixing, or style reclamation.

Runtime Guidance

  • Use rule objects for finite visual states that benefit from deterministic names and deduplication.
  • Use inline styles or CSS custom properties for high-cardinality continuous values.
  • Treat declaration values as authored CSS source. Apply application-level constraints before inserting untrusted values.
  • Keep global rules stable. Theme switching should normally update custom properties or theme classes.

Verification

dotnet run --file scripts/csharp/generate-jazor-css-properties.cs -- --check
dotnet run --file scripts/csharp/test-dotnet.cs -- --project css
dotnet run --file scripts/csharp/test-dotnet.cs -- --project css-browser
dotnet test src/Jazor.EmitTest/Jazor.EmitTest.csproj --filter JazorCss
dotnet test src/Jazor.RazorVue.Sg.Test/Jazor.RazorVue.Sg.Test.csproj --filter JazorCss

The browser smoke uses the generated runtime module and verifies computed style, CSP nonce propagation, one-style ownership, Unicode entry framing, and HMR-style module adoption.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net11.0

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
0.1.32 95 7/28/2026
0.1.31 95 7/28/2026