Skip to content
Overview

Overview

Analytical dashboards for .NET developers: a headless controller for filters, views and staged queries, and Blazor blocks that render them.

On this page

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.Dashboard.Core, 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 every dotnet add package command needs --prerelease.
  • Klyroo.Dashboard.Core alone (controller, resources, formatting, CSV) runs in any .NET 11 app.
  • A Blazor app for Klyroo.Dashboard: 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 the .Client project.
  • Klyroo.UI set up in the app. Klyroo.Dashboard brings the Klyroo.UI package, and AddKlyrooDashboard() registers its services, but the layout still needs the Klyroo.UI stylesheets in <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 under obj/klyroo. Node.js is not needed.

To build this repository you need the .NET 11 SDK (a newer SDK works too, see global.json) and a clone of klyroo-ui in the same parent folder: some projects reference it by relative path (../klyroo-ui/...). See Contributing.

Installation

Shell
dotnet add package Klyroo.Dashboard --prerelease

For headless use only, install Klyroo.Dashboard.Core instead.

Register the services in Program.cs of a Blazor Web App (and of the .Client project when you use WebAssembly or Auto), or in MauiProgram.cs:

C#
using Klyroo.Dashboard;

builder.Services.AddKlyrooDashboard();

Add the namespaces to _Imports.razor:

Razor
@using Klyroo.UI
@using Klyroo.Dashboard

Load the Klyroo.UI styles and the dashboard stylesheet in the <head> of App.razor. The dashboard stylesheet only contains the utilities the dashboard markup uses and reads the tokens that Klyroo.UI defines, so it comes after them:

Razor
<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:

C#
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, AMER

Then the same idea in Blazor. SalesService, Summary and RegionSales stand for your own data access and records:

Razor
@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.Dashboard.Core runs in any .NET 11 app (minimal APIs, workers, console apps, MAUI view models) and declares IsTrimmable and IsAotCompatible.
  • Klyroo.Dashboard needs a Blazor Web App or a .NET MAUI Blazor Hybrid app. It declares IsTrimmable but not IsAotCompatible, and declares the supported platforms browser, ios, android, maccatalyst and windows.
  • 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 KlyrooDashboardOptions.Texts (see Guides).

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.

License

MIT