https://github.com/soenneker/soenneker.lepton.suite
A foundational component system for Blazor.
https://github.com/soenneker/soenneker.lepton.suite
base basecomponent blazor blazorlibrary component componentbase csharp dotnet element elements lepton leptoncomponent suite ui
Last synced: 21 days ago
JSON representation
A foundational component system for Blazor.
- Host: GitHub
- URL: https://github.com/soenneker/soenneker.lepton.suite
- Owner: soenneker
- License: mit
- Created: 2026-04-30T00:01:19.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-06-08T21:08:20.000Z (22 days ago)
- Last Synced: 2026-06-08T22:23:32.216Z (22 days ago)
- Topics: base, basecomponent, blazor, blazorlibrary, component, componentbase, csharp, dotnet, element, elements, lepton, leptoncomponent, suite, ui
- Language: C#
- Homepage: https://soenneker.com
- Size: 96.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/soenneker.lepton.suite/)
[](https://github.com/soenneker/soenneker.lepton.suite/actions/workflows/publish-package.yml)
[](https://www.nuget.org/packages/soenneker.lepton.suite/)
[](https://soenneker.github.io/soenneker.lepton.suite)
#  Soenneker.Lepton.Suite
Small, composable Blazor component base classes for libraries that need clean defaults without buying into a UI framework.
Lepton gives component authors a consistent foundation for child content, element attributes, IDs, async disposal, and cancellation. It is not a component library. It is the base layer you build component libraries on.
## Why Lepton
- Pick exactly the component capabilities you need.
- Keep `class`, `style`, and unmatched attributes consistent across components.
- Get disposal and cancellation patterns without rewriting them in every base class.
- Type against matching interfaces when you need capability-based APIs.
## Install
```bash
dotnet add package Soenneker.Lepton.Suite
```
## Pick A Base
| Need | Use |
| --- | --- |
| Plain Blazor base | `LeptonComponent` |
| Child content | `LeptonContent` |
| Element attributes | `LeptonElement` |
| Child content + element attributes | `LeptonContentElement` |
| Id + child content + element attributes | `LeptonIdentifiableContentElement` |
| Async disposal | `LeptonDisposable` |
| Disposable content | `LeptonDisposableContent` |
| Disposable content element | `LeptonDisposableContentElement` |
| Disposable identifiable content element | `LeptonDisposableIdentifiableContentElement` |
| Disposal-bound cancellation | `LeptonCancellable` |
| Cancellable content element | `LeptonCancellableContentElement` |
| Cancellable identifiable content element | `LeptonCancellableIdentifiableContentElement` |
Every public base has a matching interface in `Soenneker.Lepton.Suite.Abstract`.
## Product Spotlight
### Consistent Element Attributes
Element bases expose `Class`, `Style`, and `AdditionalAttributes`, then build render-ready attributes for you.
```csharp
public sealed class Card : LeptonContentElement
{
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
builder.OpenElement(0, "section");
builder.AddMultipleAttributes(1, BuildAttributes("data-slot", "card"));
builder.AddContent(2, ChildContent);
builder.CloseElement();
}
}
```
```razor
Content
```
`class` and `style` values are merged instead of clobbered.
### Disposal Without Boilerplate
Disposable bases expose `ThrowIfDisposed()` and track disposal state.
```csharp
public abstract class ModuleBackedComponent : LeptonDisposable
{
private IAsyncDisposable? _module;
public override async ValueTask DisposeAsync()
{
if (_module is not null)
await _module.DisposeAsync();
await base.DisposeAsync();
}
}
```
### Cancellation That Follows Component Lifetime
Cancellable bases cancel their token during `DisposeAsync()`.
```csharp
public abstract class LoadingComponent : LeptonCancellable
{
protected Task Load()
{
ThrowIfDisposed();
return Task.Delay(TimeSpan.FromSeconds(1), CancellationToken);
}
}
```
## Design
Cancellable types are an add-on over disposable shapes:
```text
LeptonDisposableContentElement
-> LeptonCancellableContentElement
LeptonDisposableIdentifiableContentElement
-> LeptonCancellableIdentifiableContentElement
```
So if you choose a cancellable element, you still get the disposable element behavior underneath it.
## Notes
- `AdditionalAttributes` is the unmatched-attribute parameter for element bases.
- Identifiable element bases add `id` when `Id` is set.
- Cancellable bases expose a protected `CancellationToken`.
- Base classes are abstract and intended for component-library authors.