formaui-net.Framework.Themes.Browser.Interop 1.0.0-preview.27

Prefix Reserved
This is a prerelease version of formaui-net.Framework.Themes.Browser.Interop.
dotnet add package formaui-net.Framework.Themes.Browser.Interop --version 1.0.0-preview.27
                    
NuGet\Install-Package formaui-net.Framework.Themes.Browser.Interop -Version 1.0.0-preview.27
                    
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="formaui-net.Framework.Themes.Browser.Interop" Version="1.0.0-preview.27" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="formaui-net.Framework.Themes.Browser.Interop" Version="1.0.0-preview.27" />
                    
Directory.Packages.props
<PackageReference Include="formaui-net.Framework.Themes.Browser.Interop" />
                    
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 formaui-net.Framework.Themes.Browser.Interop --version 1.0.0-preview.27
                    
#r "nuget: formaui-net.Framework.Themes.Browser.Interop, 1.0.0-preview.27"
                    
#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 formaui-net.Framework.Themes.Browser.Interop@1.0.0-preview.27
                    
#: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=formaui-net.Framework.Themes.Browser.Interop&version=1.0.0-preview.27&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=formaui-net.Framework.Themes.Browser.Interop&version=1.0.0-preview.27&prerelease
                    
Install as a Cake Tool

Forma.Framework.Themes.Browser.Interop

The page's theme coordinator. One per document, it orders every theme switch on the page, keeps the accepted choice in the browser's record and in a host's store in order, and delivers it to the theme state of every runtime on the page, each Interactive Server circuit and WebAssembly runtime, so they converge on one choice, as the theme design sets out. It is built on the page state synchronizer the culture coordinator shares.

Install

dotnet add package formaui-net.Framework.Themes.Browser.Interop --prerelease

AddFormaServerIntegration() and AddFormaWebAssemblyIntegration() register it, with each runtime's registration with the coordinator and the switch that requests through it.

Switching

A component switches the page's theme through IThemeSwitch, in any runtime, and reads the choice in force through IThemeState, which tells its subscribers of each change:

@inject IThemeSwitch ThemeSwitch

<button type="button" @onclick="@(() => ThemeSwitch.SwitchAsync(new ThemeChoice("harbor", ColorSchemePreference.Dark)))">
    Harbor, dark
</button>

FormaThemePicker, in the component library, is the reader's choice made through this switch, listing only the themes whose stylesheets loaded on the page.

The switch changes the page in place, in every runtime, with no load. Its task completes once these hold:

  • the switch was accepted;
  • the browser's record holds it, where the page keeps the reader's choice;
  • the runtime that requested it applied it;
  • the host's store holds it or a newer choice, where the host registered an IThemePreferenceStore.

What a switch refuses

  • A theme that isn't selectable, one that isn't registered or whose stylesheet didn't load on the page, throws InvalidOperationException before anything changes.
  • A runtime without a registration, as in a static render, which switches with a request, throws InvalidOperationException.
  • A record the coordinator can't read back fails the switch, changing nothing.
  • A switch a later one requested through the same runtime overtook completes as canceled.
  • A store's write that fails after the switch was accepted fails the switch with the store's exception, the choice staying accepted on the page and in the record.

The store's writes

The store is written after a switch is accepted, so the page changes at once:

  • in the order the choices were accepted, one at a time, by the runtime that requested the switch, or another registered with a store where that one has gone;
  • the latest waiting, so a newer switch takes the place of a write that hasn't started, and the switch it replaced completes once the newer write does;
  • the record following the store, each completed write's revision written beside the choice accepted last.

A page given its choice by the host keeps nothing: each switch is accepted at once, writing neither the record nor the store.

A standalone app

A standalone WebAssembly app's host page links each registered theme's stylesheet, naming its theme, then loads the theme bootstrap, which names the registration's default choice. The bootstrap draws the page in the reader's choice before any of the body is parsed, from the record the app keeps in local storage:

<link rel="stylesheet" href="_content/Forma.Blazor/forma-tokens.css" data-forma-theme-stylesheet="forma" />
<link rel="stylesheet" href="_content/Forma.Blazor/forma-high-contrast.css" data-forma-theme-stylesheet="forma-high-contrast" />
<link rel="stylesheet" href="css/harbor-theme.css" data-forma-theme-stylesheet="harbor" />
<script src="_content/forma/themes/scripts/ThemeBootstrap.js" data-default-theme="harbor" data-default-scheme="system"></script>

A theme with a light scheme alone says so on its link, data-forma-theme-schemes="light". A record naming a theme the page doesn't link, or one whose stylesheet failed, draws the default theme in the record's scheme preference; no record, an unreadable one, or storage the browser refuses to open draws the default choice. A host page whose themes or default differ from the registration fails the runtime's start with InvalidOperationException naming each difference.

License

Apache License 2.0, under the repository's LICENSE.

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.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on formaui-net.Framework.Themes.Browser.Interop:

Package Downloads
formaui-net.Blazor

A Blazor component library for .NET 11: form inputs and pickers, dialogs, popovers and toasts, toolbars and menus, tabs and layout, file pickers, uploaders and viewers, icons, emoji and windows.

formaui-net.Blazor.WebView

The WebView half of Forma's component library: the registration a Blazor Hybrid application makes, in WPF, Windows Forms or MAUI on Windows, or MAUI on Android, iOS or Mac Catalyst, which registers what the components need in a web view, the culture its web views keep, one for the whole application by default, or one for each web view, and the theme every web view draws, the application's.

formaui-net.Framework.Themes.Blazor.WebAssembly

What the theme state needs from a WebAssembly client: the runtime's state registered with the page's theme coordinator of Forma.Framework.Themes.Browser.Interop as the runtime starts, before it renders, and the switch that requests through it.

formaui-net.Framework.Themes.Blazor.Server

The theme system's server half: each request's theme choice, resolved from a host's store, the browser's record and the default, the record kept beside the store, a choice a host gives a request, the theme marker a page publishes, the endpoint a statically rendered picker posts to, and the variation a host's output cache adds.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.27 59 12/3/2026
1.0.0-preview.26 72 12/3/2026
1.0.0-preview.25 74 12/2/2026
1.0.0-preview.24 90 12/1/2026
1.0.0-preview.23 128 11/30/2026
1.0.0-preview.22 132 11/30/2026
1.0.0-preview.21 133 11/29/2026

What this release changed is in Forma's changelog: https://github.com/FormaUI/Forma/blob/v1.0.0-preview.27/CHANGELOG.md