Skip to content

Tharga/Blazor

Repository files navigation

Tharga.Blazor

NuGet Nuget License

Generic reusable Blazor UI components. Works with both Blazor Server and Blazor WebAssembly. Built on Radzen.Blazor.

Documentation: blazor.tharga.net

Installation

dotnet add package Tharga.Blazor

Setup

Register services in Program.cs:

builder.Services.AddThargaBlazor(o => o.Title = "My Application");

You can also bind configuration from appsettings.json:

builder.Services.AddThargaBlazor(configuration: builder.Configuration);

Or combine both (code overrides config):

builder.Services.AddThargaBlazor(o => o.Title = "My App", configuration: builder.Configuration);

Configuration section in appsettings.json:

{
  "Tharga": {
    "Blazor": {
      "Title": "Application Name"
    }
  }
}

This registers:

  • BreadCrumbService (scoped)
  • ILocalStorageService from Blazored.LocalStorage
  • IOptions<BlazorOptions> for configuration

Components

Buttons

Pre-built button components with busy states and error handling.

  • ActionButton — Wraps async click actions with automatic loading state, error notifications, and optional delay.
  • StandardButton — Base button with typed styling (Normal, Discrete, Information, Warning, Error, Confirm, Reject).
  • CancelButton — Pre-styled cancel button.
  • CopyButton — Copies text to clipboard via JS interop with success notification.

Breadcrumbs

Route-aware breadcrumb trail with programmatic control.

<BreadCrumbs />

Use BreadCrumbService to customize the trail:

@inject BreadCrumbService BreadCrumbService

// Add a virtual segment
BreadCrumbService.AddVirtualSegment("Details", "/items/42");

// Convert a query parameter into a breadcrumb
BreadCrumbService.RegisterVirtualSegmentQueryParam("category");

// Relink or unlink segments
BreadCrumbService.RelinkSegment("Items", "/items?status=active");
BreadCrumbService.UnlinkSegment("Current");

Error Handling

<CustomErrorBoundary>
    <ChildContent>@Body</ChildContent>
</CustomErrorBoundary>

Catches unhandled exceptions, logs them with a correlation ID, and displays an error view with recovery.

Layout & Display

  • ExpandableCard — Collapsible card with optional icon, header menu, and local storage state persistence.
  • Loading — Indeterminate progress indicator (centered or inline).
  • Title — Dynamic page title based on route and BlazorOptions.Title.
  • DateTimeView — Formatted date/time display with relative duration tooltip.
  • TimeSpanView — Formatted time span display.

Target Frameworks

  • .NET 9
  • .NET 10

Dependencies

Build & Test

dotnet build -c Release
dotnet test -c Release

License

MIT

About

Common blazor components

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors