formaui-net.Framework.Icons 1.0.0-preview.27

Prefix Reserved
This is a prerelease version of formaui-net.Framework.Icons.
dotnet add package formaui-net.Framework.Icons --version 1.0.0-preview.27
                    
NuGet\Install-Package formaui-net.Framework.Icons -Version 1.0.0-preview.27
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="formaui-net.Framework.Icons" Version="1.0.0-preview.27" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="formaui-net.Framework.Icons" Version="1.0.0-preview.27" />
                    
Directory.Packages.props
<PackageReference Include="formaui-net.Framework.Icons" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add formaui-net.Framework.Icons --version 1.0.0-preview.27
                    
#r "nuget: formaui-net.Framework.Icons, 1.0.0-preview.27"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package formaui-net.Framework.Icons@1.0.0-preview.27
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=formaui-net.Framework.Icons&version=1.0.0-preview.27&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=formaui-net.Framework.Icons&version=1.0.0-preview.27&prerelease
                    
Install as a Cake Tool

Forma.Framework.Icons

The icon contracts for Forma: Icon, which names what to draw, a glyph, a brand mark or a character; IconSize, the size it is drawn at; IconArtwork, the geometry or character that draws it; and IIconProvider, which answers an icon with its artwork. Reference it to draw Forma's icons with a set of your own, or to name icons in a library of your own.

Install

dotnet add package formaui-net.Framework.Icons --prerelease

Naming an icon

Type What it is
Icon What an icon draws: a GlyphIcon, a BrandIcon or a CharacterIcon.
Glyph A mark named for its recognizable form, ArrowLeft, ChevronDown, Folder, or for its conventional meaning, Search, Delete, Settings.
GlyphVariant Default, the provider's primary representation, or Alternate, its alternate one.
Brand A brand whose official mark is drawn: GitHub, X, YouTube.
IconSize Inline with the surrounding text, Small on a button or in a dense row, Medium leading a panel or a tile, Large as a section's figure, Display as the figure of an empty state or a drop zone.

A Glyph, a Brand or a Rune converts to an Icon, and Icon.FromGlyph names a variant:

using System.Text;

using Forma.Framework.Icons;

Icon save = Glyph.Save;
Icon heart = Icon.FromGlyph(Glyph.Heart, GlyphVariant.Alternate);
Icon gitHub = Brand.GitHub;
Icon omega = new Rune('Ω');

Icons are records, so two icons naming the same glyph in the same variant are equal.

Direction

Glyph artwork is drawn for left-to-right text. A glyph whose form points along the reading direction, such as an arrow, a chevron or Undo, declares the direction it adapts for as the HTML dir token, and FormaIcon draws it turned over where text runs that way:

Glyph.ArrowLeft.GetDirectionSensitivity();    // "rtl"
Glyph.ArrowLeft.IsDirectionSensitive("rtl");  // true
Glyph.AlignLeft.GetDirectionSensitivity();    // null

Artwork

Type What it is
IconArtwork The artwork used to draw an icon: an IconVector, a BrandIconArtwork or an IconCharacter. IconArtwork.None is nothing to draw.
IconVector SVG geometry: a ViewBox and the Paths composing it, in painting order. Built by IconArtwork.Vector(viewBox, paths).
BrandIconArtwork An IconVector carrying the brand's name as Title. Built by IconArtwork.Brand(viewBox, paths, title).
IconCharacter A single character drawn by the font: its Value. Built by IconArtwork.Character(value).
IconPath One path: its SVG path Data, its Opacity, and its StrokeWidth in the artwork's own units, where zero fills the path.

Implementing a provider

Member What it does
bool TryGetArtwork(Icon icon, IconSize size, out IconArtwork artwork) Gets the artwork for an icon at a size, returning whether the provider has it.
IconArtwork GetArtwork(Icon icon, IconSize size) Gets the artwork for an icon at a size, throwing ArgumentOutOfRangeException where the provider has none.

The size lets a provider answer with artwork drawn for that size. A provider answers the icons it carries and declines the rest with IconArtwork.None:

using Forma.Framework.Icons;

public sealed class HouseIconProvider : IIconProvider
{
    private static readonly IconArtwork SaveArtwork = IconArtwork.Vector(
        "0 0 24 24",
        [
            new IconPath { Data = "M5 3h11l3 3v15H5z", StrokeWidth = 2 },
            new IconPath { Data = "M8 3v6h7V3", StrokeWidth = 2 },
        ]);

    public bool TryGetArtwork(Icon icon, IconSize size, out IconArtwork artwork)
    {
        switch (icon)
        {
            case GlyphIcon { Glyph: Glyph.Save }:
                artwork = SaveArtwork;
                return true;
            case CharacterIcon character:
                artwork = IconArtwork.Character(character.Character);
                return true;
            default:
                artwork = IconArtwork.None;
                return false;
        }
    }

    public IconArtwork GetArtwork(Icon icon, IconSize size)
        => TryGetArtwork(icon, size, out var artwork)
            ? artwork
            : throw new ArgumentOutOfRangeException(nameof(icon), $"No artwork for {icon}.");
}

Register it as the IIconProvider on each side that renders icons, in any order beside AddFormaServerIntegration() and AddFormaWebAssemblyIntegration(), which register no icon provider of their own:

builder.Services.AddSingleton<IIconProvider, HouseIconProvider>();
builder.AddFormaServerIntegration();

FormaIcon also takes a provider for one icon through its Provider parameter, or for a subtree as a cascading IIconProvider; the registered provider answers whatever that provider declines.

Reading artwork

Draw by the kind of artwork the provider returns, matching BrandIconArtwork before the IconVector it derives from:

using Forma.Framework.Icons;

if (provider.TryGetArtwork(Glyph.Delete, IconSize.Small, out var artwork))
{
    switch (artwork)
    {
        case BrandIconArtwork brand:
            // brand.ViewBox, brand.Paths, brand.Title
            break;
        case IconVector vector:
            // vector.ViewBox, vector.Paths
            break;
        case IconCharacter character:
            // character.Value
            break;
    }
}

formaui-net.Framework.Icons.Glyphs is Forma's own icon set and the default provider.

License

Apache License 2.0, under the repository's LICENSE.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net11.0

    • No dependencies.

NuGet packages (13)

Showing the top 5 NuGet packages that depend on formaui-net.Framework.Icons:

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.Framework.Icons.Glyphs

Forma's own icon set, as an IIconProvider from Forma.Framework.Icons: every Glyph in both variants, every Brand as its official mark, and any character.

formaui-net.Framework.Windows

The workspace behind Forma's windows.

formaui-net.Framework.Share

The share contracts: the item a share menu acts on, the targets an item can be shared to, and the sources a host answers a user's credentials through.

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.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.27 71 12/3/2026
1.0.0-preview.26 83 12/3/2026
1.0.0-preview.25 88 12/2/2026
1.0.0-preview.24 120 12/1/2026
1.0.0-preview.23 180 11/30/2026
1.0.0-preview.22 170 11/30/2026
1.0.0-preview.21 176 11/29/2026
1.0.0-preview.20 180 11/26/2026
1.0.0-preview.19 183 11/26/2026
1.0.0-preview.18 168 11/26/2026
1.0.0-preview.17 156 11/26/2026
1.0.0-preview.16 150 11/24/2026
1.0.0-preview.15 151 11/23/2026
1.0.0-preview.14 158 11/23/2026
1.0.0-preview.13 147 11/21/2026
1.0.0-preview.12 144 11/20/2026
1.0.0-preview.11 145 11/18/2026
1.0.0-preview.10 151 11/17/2026
1.0.0-preview.9 184 11/17/2026
1.0.0-preview.8 161 11/17/2026
Loading failed

What this release changed is in Forma's changelog: https://github.com/FormaUI/Forma/blob/v1.0.0-preview.27/CHANGELOG.md