formaui-net.Framework.Css
1.0.0-preview.27
Prefix Reserved
dotnet add package formaui-net.Framework.Css --version 1.0.0-preview.27
NuGet\Install-Package formaui-net.Framework.Css -Version 1.0.0-preview.27
<PackageReference Include="formaui-net.Framework.Css" Version="1.0.0-preview.27" />
<PackageVersion Include="formaui-net.Framework.Css" Version="1.0.0-preview.27" />
<PackageReference Include="formaui-net.Framework.Css" />
paket add formaui-net.Framework.Css --version 1.0.0-preview.27
#r "nuget: formaui-net.Framework.Css, 1.0.0-preview.27"
#:package formaui-net.Framework.Css@1.0.0-preview.27
#addin nuget:?package=formaui-net.Framework.Css&version=1.0.0-preview.27&prerelease
#tool nuget:?package=formaui-net.Framework.Css&version=1.0.0-preview.27&prerelease
Forma.Framework.Css
Typed CSS values and attribute builders for Blazor markup. CssLength, CssColor and CssColorValue render
themselves as valid, culture-invariant CSS, and CssClassBuilder and CssStyleBuilder collect
what an element carries and render it as one class or style attribute value.
Install
dotnet add package formaui-net.Framework.Css --prerelease
Every type is created directly; there is nothing to register.
| Type | What it is |
|---|---|
CssClassBuilder |
Collects class names and renders them space-separated. |
CssStyleBuilder |
Collects declarations and renders them as property: value; pairs. |
CssLength |
An immutable measurement with a unit, rendered as 20rem, 6ch or 50%. |
CssLengthUnit |
The unit of a CssLength: Ch, Em, Percent, Px or Rem. |
CssColor |
An immutable RGBA color, rendered as #rrggbb or rgba(r, g, b, a). |
CssColorValue |
A color as a style takes it: a CssColor, or a custom property rendered as var(--name). |
Classes
Add takes a class name, optionally with the condition under which it applies, and skips a blank
name. ToStringOrNull returns null when nothing was added, so Blazor omits the attribute.
@using Forma.Framework.Css
<button class="@Classes.ToStringOrNull()">Save</button>
@code {
[Parameter] public bool IsPrimary { get; set; }
[Parameter] public bool IsBusy { get; set; }
private CssClassBuilder Classes => new CssClassBuilder()
.Add("app-button")
.Add("app-button--primary", IsPrimary)
.Add("app-button--busy", IsBusy);
}
IsEmpty says whether anything was added, and Clear empties the builder.
Styles
Add takes a property with a typed value, a CssLength or a CssColorValue, which renders as
nothing but that value, so a value that came from data can't add a declaration of its own; a
conditional overload adds a length only while its condition holds. AddDeclarations adds
declarations already written as CSS text, such as a host's own style. A null value adds nothing,
and every declaration is terminated with ;.
using Forma.Framework.Css;
CssLength? height = null;
var isFloating = true;
var style = new CssStyleBuilder()
.Add("inline-size", CssLength.FromRem(18.5))
.Add("block-size", height)
.Add("inset-inline-start", CssLength.FromPx(40), isFloating)
.Add("color", CssColor.FromHex(0x663399))
.AddDeclarations("--app-accent: rebeccapurple");
style.ToString(); // "inline-size: 18.5rem; inset-inline-start: 40px; color: #663399; --app-accent: rebeccapurple;"
Lengths
A length is created through the factory for its unit and renders with up to four decimal places.
A non-finite value throws ArgumentOutOfRangeException.
CssLength.FromCh(6).ToString(); // "6ch"
CssLength.FromRem(1.25).ToString(); // "1.25rem"
CssLength.FromPercent(50).ToString(); // "50%"
CssLength.FromPx(12).Unit; // CssLengthUnit.Px
Colors
A color is created from a packed 24-bit value or from its channels, with an optional opacity from
0 to 1. ToString renders #rrggbb for an opaque color and rgba(r, g, b, a) otherwise;
ToHexString and ToRgbaString render one form always. A packed value outside 0x000000 to
0xFFFFFF or an opacity outside 0 to 1 throws ArgumentOutOfRangeException.
CssColor.FromHex(0x2c384a).ToString(); // "#2c384a"
CssColor.FromRgba(98, 105, 118, 0.12).ToString(); // "rgba(98, 105, 118, 0.12)"
CssColor.FromRgb(255, 193, 7).IsOpaque; // true
Colors a theme defines
A CssColorValue is what a style paints with: a literal CssColor, or the custom property a theme defines
a color in, read where the style applies, so a theme that redefines the property recolors what reads it. A
CssColor converts to one implicitly. A property's name starts with two hyphens and holds letters, digits,
hyphens and underscores; any other name throws InvalidOperationException.
CssColorValue.FromProperty("--success-subtle-color").ToString(); // "var(--success-subtle-color)"
CssColorValue literal = CssColor.FromHex(0x2c384a); // renders "#2c384a"
License
Apache License 2.0, under the repository's LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- No dependencies.
NuGet packages (8)
Showing the top 5 NuGet packages that depend on formaui-net.Framework.Css:
| Package | Downloads |
|---|---|
|
formaui-net.Framework.Toolbar
The item model Forma's toolbars render: a toolbar described as a list of records, each a command, a toggle, a menu of options, a readout or a component of the caller's own, grouped or standing alone. |
|
|
formaui-net.Blazor
A Blazor component library for .NET 11: form inputs and pickers, dialogs, popovers and toasts, toolbars and menus, tabs and layout, file pickers, uploaders and viewers, icons, emoji and windows. |
|
|
formaui-net.Framework.Feedback
The services behind Forma's feedback surfaces: a toast service any code raises a notice through, a confirm dialog service any code awaits a yes or no from, and a catalog of the statuses an application's badges are named after. |
|
|
formaui-net.Blazor.Explorer
FormaExplorer, a file manager for the Forma component library over items and folders the host already holds: a folder tree, an address bar with history and breadcrumbs, thumbnail, details and list views, search, sorting and grouping, selection, drag and drop between folders, upload, and a preview of any item. |
|
|
formaui-net.Blazor.DataView
FormaDataView, the collection component of the Forma component library. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-preview.27 | 69 | 12/3/2026 |
| 1.0.0-preview.26 | 77 | 12/3/2026 |
| 1.0.0-preview.25 | 83 | 12/2/2026 |
| 1.0.0-preview.24 | 105 | 12/1/2026 |
| 1.0.0-preview.23 | 154 | 11/30/2026 |
| 1.0.0-preview.22 | 152 | 11/30/2026 |
| 1.0.0-preview.21 | 154 | 11/29/2026 |
| 1.0.0-preview.20 | 139 | 11/26/2026 |
| 1.0.0-preview.19 | 146 | 11/26/2026 |
| 1.0.0-preview.18 | 144 | 11/26/2026 |
| 1.0.0-preview.17 | 132 | 11/26/2026 |
| 1.0.0-preview.16 | 114 | 11/24/2026 |
| 1.0.0-preview.15 | 106 | 11/23/2026 |
| 1.0.0-preview.14 | 111 | 11/23/2026 |
| 1.0.0-preview.13 | 105 | 11/21/2026 |
| 1.0.0-preview.12 | 107 | 11/20/2026 |
| 1.0.0-preview.11 | 109 | 11/18/2026 |
| 1.0.0-preview.10 | 107 | 11/17/2026 |
| 1.0.0-preview.9 | 149 | 11/17/2026 |
| 1.0.0-preview.8 | 117 | 11/17/2026 |
What this release changed is in Forma's changelog: https://github.com/FormaUI/Forma/blob/v1.0.0-preview.27/CHANGELOG.md