Platforms
Where Klyroo.UI runs, what each environment needs, and what does not work there. Everything below is read from the project files and the code of this repository.
On this page
Render modes
Every component works in static server rendering, Interactive Server, WebAssembly and Auto, with the same markup. Use the standard Blazor render mode attributes: nothing Klyroo-specific is needed.
| Mode | What works | What does not |
|---|---|---|
| Static server rendering | Form controls render real fields and post. Overlays, tabs, accordions, popovers, tooltips, the color mode controls and KlyLocaleSelect work, because their behavior is in the browser. |
Anything that changes the page from a .NET handler. A KlyButton with OnClick and the sort buttons of KlyTable are disabled until the page is interactive. IToastService needs JavaScript interop. |
| Interactive Server | Everything. Bound values and handlers run on the server. | Cookies cannot be read after the prerender: there is no HTTP request in a circuit. |
| WebAssembly | Everything. Handlers run in the browser. | Klyroo. and Klyroo. are server packages and do not belong in a client project. |
| Auto | Everything. The first render is on the server and later ones on WebAssembly. | Configuration that differs between the two projects changes the appearance when the runtime switches. |
What decides the behavior is who owns the state. Opening, closing, focus, keyboard navigation and positioning run in
custom elements in the browser, so an overlay without @bind-Open never calls .NET. A value you bind with
@bind-Value or @bind-Open is reported to .NET with a custom event. See Concepts.
Requirements for every mode:
- Call
AddKlyrooUiwith the same options in the server project and in the.project of a WebAssembly or Auto app. A shared extension method in the client project keeps both in sync.Client - Put the head components in
App.:razor KlyColor,Mode Script KlyThemeStyle,KlyCultureMetaandKlyFontsas you need them. They render the same in static rendering, prerendering and every interactive mode. - Declare
KlyrooFontitems in the server project, never in a WebAssembly project (KLYFONT010). - A
KlyApporKlyThemedoes not reach a component that has its own@rendermode, because cascading values do not cross a render mode boundary. Place one inside that island, or useAddKlyrooUi. - Call
Applyin the clientServer Culture Async Program.so the WebAssembly runtime formats with the culture the server used. See Localize the app.cs
Features that read the request, such as the time zone cookie of a data list in a sister package, need
Klyroo. in the server project and builder.. Without it the feature falls back to a
default and does not fail. The package depends on exactly the version of Klyroo. it was built with.
Sister packages can hand data from the prerender to the interactive render (the results of a Klyroo.Table list, the
resources of a Klyroo.Dashboard). The browser sends all of it back to the server in the message that starts an
Interactive Server circuit, which SignalR refuses past 32 KB by default, and the circuit then fails to start. So the
packages of a page share one budget, KlyrooOptions. (28 KB by default, counted as sent, with the
escaping and the two base64 encodings Blazor adds), through the scoped KlyPersisted. What does not fit is
not handed over: that list or resource loads again once in the interactive render. Raise the budget only together with
the Maximum of the hub.
Choosing a UI package
| App | UI package | How it renders |
|---|---|---|
| Blazor web | Klyroo. |
Razor in the browser, with static server rendering, Interactive Server, WebAssembly or Auto. |
| .NET MAUI Blazor Hybrid | Klyroo. |
The same Razor components inside a BlazorWebView on Android, iOS, Mac Catalyst or Windows. |
| Native .NET MAUI | Klyroo. |
Native MAUI views on the same four platforms, using C# controls. |
Klyroo. brings in the existing Klyroo. package, preserving its namespaces and static asset paths. The Klyroo. and Klyroo. package projects are available from source.
Native .NET MAUI controls
Blazor Hybrid draws the UI in a web view. For an app with real native views, Klyroo. provides MAUI controls
(KlyButton, KlyInput, KlySwitch, ...) with the same design tokens, in plain C# with no WebView and no Blazor. It covers a subset of the components,
and the sample is samples/. The project is separate from the Razor library and is available from source.
.NET MAUI Blazor Hybrid
The same components run in a BlazorWebView, so one set of pages can ship as a web app and as a native app. A web
view is always interactive, has no prerendering, no HttpContext and no server to read cookies or to write the page
head. The components that depend on a server degrade to what a web view can do.
The sample in samples/ has a shared Razor class library with the pages, a MAUI
head and a web head that run the same pages. Its MAUI project targets Android on every host, iOS and Mac Catalyst
except on Linux, and Windows on a Windows host.
To use Klyroo.UI in a MAUI app:
- Reference
Klyroo.from the shared project and callUI AddKlyrooUifromMauiProgram., aftercs AddMaui:Blazor Web View
using Klyroo.UI;
// MauiProgram.cs, after builder.Services.AddMauiBlazorWebView();
builder.Services.AddKlyrooUi(o => o.Colors.Primary = KlyPalette.Blue);- Link the stylesheets from
wwwroot/. Give the viewportindex. html viewport-fit=coverso the page uses the whole screen; Klyroo keeps its content inside the safe area:
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<link rel="stylesheet" href="_content/Klyroo.UI/klyroo.preflight.css" />
<link rel="stylesheet" href="_content/Klyroo.UI/klyroo.css" />- Add a
HeadOutletroot component with the selectorhead::afternext to the root component of the app, so the head content has somewhere to go:
<blazor:BlazorWebView x:Name="blazorWebView" HostPage="wwwroot/index.html">
<blazor:BlazorWebView.RootComponents>
<blazor:RootComponent Selector="#app" ComponentType="{x:Type shared:Routes}" />
<blazor:RootComponent Selector="head::after" ComponentType="{x:Type web:HeadOutlet}" />
</blazor:BlazorWebView.RootComponents>
</blazor:BlazorWebView>- Put
KlyHeadonce in the layout, next toKlyApp. It sends the theme variables and the self-hosted fonts to the head throughHeadContent, which a web view cannot receive from a server. It renders nothing in a browser.
@inherits LayoutComponentBase
<KlyHead />
<KlyApp>
<KlyMain>@Body</KlyMain>
</KlyApp>Platform minimums, from the sample project: Klyroo.UI needs the native popover API in the web view, which means iOS 17 and Mac Catalyst 17 and, on Android, a current System WebView (Chrome 114 or later; the app itself runs from Android 7.0, API 24). The Windows target is set to 10.0.17763.0.
What changes in a web view:
| Feature | In a web view |
|---|---|
| Culture | KlyLocaleSelect stores the choice through IKlyCultureStore, by default in localStorage (KlyLocal). Register your own store, such as one over Preferences, and call Apply before the first render to start in the right language. |
| Cookies | There is no server to read them. Klyroo. does nothing here. |
KlyCultureMeta |
Renders nothing, and Apply keeps the culture of the device. |
| Images | Klyroo. is an ASP.NET Core endpoint and is not available. Use a CDN provider or local files. |
| Head | KlyHead and a HeadOutlet root component replace the head of App.. |
| Touch | Targets reach 44 px on coarse pointers. |
| Host detection | KlyrooHost. tells a web view from a browser; the page also gets data-kly-host="webview" on <html>. |
<Kly turns on an experimental mode for TV screens that serves remote controls.
Trimming and NativeAOT
Klyroo., Klyroo. and Klyroo. set IsAotCompatible, which turns on the trimming, AOT and single-file
analyzers and marks the assembly trimmable. They build with no warning from those analyzers, and the build treats warnings as
errors, so a change that adds reflection the trimmer cannot see fails the build. The components avoid reflection in their
interop: calls into JavaScript pass strings and numbers, event handlers carry Dynamic attributes so their
event arguments survive trimming, and the generic radio group carries the annotation that InputRadioGroup
requires. The dialogs of IKly open the component you name with ShowAsync, a generic method
that carries the annotation Blazor needs to keep the constructors and properties of that type. Klyroo. does
not set IsAotCompatible or IsTrimmable, because it depends on NetVips and its native binaries.
The declaration says the library code is clean under the analyzers. It is not a test of a published NativeAOT app: Blazor itself, your own components and your own libraries decide whether an app can be published that way. Publish your app with the setting you intend to use and test it.
Supported platform
Klyroo. declares Supported browser: it targets code that runs in a browser or in a web view. The
stylesheets and the JavaScript are static web assets, so any host that serves static web assets can serve them.
The target framework of every package is net11.0.