Overview
Analytical dashboards for .NET developers: a headless controller for filters, views and staged queries, and Blazor blocks that render them.
A dashboard usually fires a dozen queries and one slow or failing query should not blank the page. Klyroo.Dashboard
tracks each query as a resource with its own state, loads the important ones first, and gives every block its own
loading, error and empty states. The state lives in Klyroo., which has no UI dependency, so you can
test it without a renderer. The Blazor components run in a Blazor Web App and in .NET MAUI Blazor Hybrid.
Prerequisites
To use the library in an app:
- The .NET 11 SDK, and an app that targets
net11.0. The packages are prereleases, so everydotnet add packagecommand needs--prerelease. Klyroo.alone (controller, resources, formatting, CSV) runs in any .NET 11 app.Dashboard. Core - A Blazor app for
Klyroo.: a Blazor Web App or a .NET MAUI Blazor Hybrid app. Tabs, filters, refresh, sorting and the card menu need an interactive render mode (Interactive Server, WebAssembly or Auto). In a WebAssembly or Auto app, register the services in the server project and in theDashboard .project.Client - Klyroo.UI set up in the app.
Klyroo.brings the Klyroo.UI package, andDashboard AddKlyrooregisters its services, but the layout still needs the Klyroo.UI stylesheets inDashboard() <head>and<KlyApp>around the body, as described in the Klyroo.UI installation. - A browser with the native popover API, which Klyroo.UI uses: Chrome and Edge 114, Safari 17 or Firefox 125, or later. In a .NET MAUI app, that means iOS or Mac Catalyst 17, or an Android System WebView 114 or later.
- Network access on the first build only if your app self-hosts web fonts (
KlyrooFont), uses icons outside the built-in set, or compiles Tailwind (KlyrooTailwind): the build downloads them once and caches them underobj/. Node.js is not needed.klyroo
To build this repository you need the .NET 11 SDK (a newer SDK works too, see global.) and a clone of klyroo-ui in the same parent folder: some projects reference it by relative path (../). See Contributing.
Installation
dotnet add package Klyroo.Dashboard --prereleaseFor headless use only, install Klyroo. instead.
Register the services in Program. of a Blazor Web App (and of the . project when you use WebAssembly or Auto), or in MauiProgram.:
using Klyroo.Dashboard;
builder.Services.AddKlyrooDashboard();Add the namespaces to _:
@using Klyroo.UI
@using Klyroo.DashboardLoad the Klyroo.UI styles and the dashboard stylesheet in the <head> of App.. The dashboard stylesheet only contains the utilities the dashboard markup uses and reads the tokens that Klyroo.UI defines, so it comes after them:
<link rel="stylesheet" href="@Assets["_content/Klyroo.UI/klyroo.preflight.css"]" />
<link rel="stylesheet" href="@Assets["_content/Klyroo.UI/klyroo.css"]" />
<link rel="stylesheet" href="@Assets["_content/Klyroo.Dashboard/klyroo-dashboard.css"]" />Quick start
Headless first. Two resources, one per stage, loaded by a single call:
using Klyroo.Dashboard;
var controller = new DashboardController("sales");
var revenue = controller.RegisterResource(new DashboardResource<double>(
"revenue", async _ => { await Task.Delay(50); return 48_500; }));
var regions = controller.RegisterResource(new DashboardResource<string[]>(
"regions", _ => Task.FromResult(new[] { "EMEA", "AMER" }), DashboardQueryStage.Background));
await controller.RefreshAsync();
Console.WriteLine(DashboardFormat.Format(revenue.Data, DashboardFormatPreset.Compact)); // 48.5K
Console.WriteLine(string.Join(", ", regions.Data!)); // EMEA, AMERThen the same idea in Blazor. SalesService, Summary and RegionSales stand for your own data access and records:
@inject SalesService Sales
<KlyDashboardPage Dashboard="_dashboard" Title="Sales" Description="Revenue and orders by region">
<KlyDashboardGrid Freshness="true">
<KlyDashboardStat Source="_summary" Label="Revenue" Span="4"
Value="_summary.Data?.Revenue" Compare="_summary.Data?.PreviousRevenue"
Format="DashboardFormatPreset.Compact" />
<KlyDashboardStat Source="_summary" Label="Orders" Span="4"
Value="_summary.Data?.Orders" Format="DashboardFormatPreset.Integer" />
<KlyDashboardGauge Source="_summary" Title="Quota" Span="4" Value="84" Target="90"
Format="DashboardFormatPreset.Percent" />
<KlyDashboardBars Source="_regions" Title="Revenue by region" Span="12"
Items="_regions.Data?.Select(r => new DashboardBarItem(r.Region, r.Revenue)).ToList()"
Format="DashboardFormatPreset.Compact" />
</KlyDashboardGrid>
</KlyDashboardPage>
@code {
private readonly DashboardController _dashboard = new("sales");
private DashboardResource<Summary> _summary = default!;
private DashboardResource<IReadOnlyList<RegionSales>> _regions = default!;
protected override async Task OnInitializedAsync()
{
_summary = _dashboard.RegisterResource(
new DashboardResource<Summary>("summary", ct => Sales.GetSummaryAsync(null, ct)));
_regions = _dashboard.RegisterResource(
new DashboardResource<IReadOnlyList<RegionSales>>(
"regions", ct => Sales.GetRegionsAsync(null, ct), DashboardQueryStage.Background));
await _dashboard.RefreshAsync();
}
}A block does not read the data of its Source: the source only drives the loading, error and empty states, and you pass the values through the block parameters.
Documentation
| Getting started | Step-by-step first integration |
| Guides | Task-oriented recipes |
| Concepts | How the library works |
| Platforms | Render modes, .NET MAUI, NativeAOT |
| API reference | Every public type and member |
| FAQ | Troubleshooting and limitations |
Compatibility
- .NET 11 SDK.
Klyroo.runs in any .NET 11 app (minimal APIs, workers, console apps, MAUI view models) and declaresDashboard. Core IsTrimmableandIsAotCompatible.Klyroo.needs a Blazor Web App or a .NET MAUI Blazor Hybrid app. It declaresDashboard IsTrimmablebut notIsAotCompatible, and declares the supported platformsbrowser,ios,android,maccatalystandwindows.- Static SSR renders the blocks, but tabs, filter controls, the refresh button, the table sort and the copy and CSV buttons need an interactive render mode (Interactive Server, WebAssembly or Auto).
- The block texts (Refresh, View as table, Retry and so on) follow the Klyroo.UI locale in the 12 languages of Klyroo.UI, English and French reviewed and the others drafts. Change them with
Klyroo(see Guides).Dashboard Options. Texts
Contributing
Contributions are welcome. Read CONTRIBUTING.md before opening a pull request, and follow the code of conduct. Report security issues privately as described in SECURITY.md.