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

Prefix Reserved
This is a prerelease version of formaui-net.Framework.Emojis.
dotnet add package formaui-net.Framework.Emojis --version 1.0.0-preview.27
                    
NuGet\Install-Package formaui-net.Framework.Emojis -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.Emojis" 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.Emojis" Version="1.0.0-preview.27" />
                    
Directory.Packages.props
<PackageReference Include="formaui-net.Framework.Emojis" />
                    
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.Emojis --version 1.0.0-preview.27
                    
#r "nuget: formaui-net.Framework.Emojis, 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.Emojis@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.Emojis&version=1.0.0-preview.27&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=formaui-net.Framework.Emojis&version=1.0.0-preview.27&prerelease
                    
Install as a Cake Tool

Forma.Framework.Emojis

The emoji contracts for Forma: Emoji, the value that names one emoji; IEmojiProvider, which gives the artwork an emoji is drawn with; and IEmojiCatalog, the emoji a picker browses and searches. Implement a provider to draw emoji with your own artwork, and a catalog to choose the emoji FormaEmojiPicker offers.

Install

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

Naming an emoji

An Emoji is one character, however many scalar values it takes: a flag, a skin-toned hand and a family sequence are each one emoji. A string converts implicitly, and TryCreate checks text that may hold more or less than one character:

using Forma.Framework.Emojis;

Emoji smile = "😀";
Emoji family = "👨‍👩‍👧";

if (Emoji.TryCreate(userInput, out var emoji))
{
    // emoji.Sequence holds the scalar values
}

Providing artwork

Type What it is
IEmojiProvider Provides artwork for emoji: GetArtwork(Emoji) returns the EmojiArtwork to draw it with.
EmojiArtwork The artwork used to draw an emoji: EmojiArtwork.Unicode, the platform's emoji font; EmojiArtwork.Sprite(symbol, sheet), a symbol in a sprite sheet; or EmojiArtwork.Image(url), a standalone image.
EmojiSprite Sprite artwork: its Symbol and the Sheet it is loaded from.
EmojiImage Image artwork: its Url.

A provider answers every emoji with artwork, and EmojiArtwork.Unicode hands an emoji to the platform's font. This one draws each emoji from an image named by its code points:

using System.Globalization;

using Forma.Framework.Emojis;

public sealed class CdnEmojiProvider : IEmojiProvider
{
    public EmojiArtwork GetArtwork(Emoji emoji)
    {
        var codepoints = string.Join("-", emoji.Sequence.EnumerateRunes()
            .Select(rune => rune.Value.ToString("x", CultureInfo.InvariantCulture)));

        return EmojiArtwork.Image($"https://cdn.example.test/emoji/{codepoints}.svg");
    }
}

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

builder.Services.AddSingleton<IEmojiProvider, CdnEmojiProvider>();
builder.AddFormaServerIntegration();

Providing a catalog

Type What it is
IEmojiCatalog The emoji a host offers: TryFindByGroupId lists a category, TryGetByEmoji finds one emoji's entry, and Find returns the entries whose name or keywords match every whitespace-separated term.
EmojiInfo One emoji in a catalog: its Emoji, English Name, search Keywords and GroupId.
EmojiGroup One category: its Id and its English Title, which is also its localization key.
NullEmojiCatalog The catalog holding no emoji, as NullEmojiCatalog.Instance.

Each entry's GroupId is one of the categories the picker lists: FormaEmojiPicker.DefaultGroups holds smileys, people, animals, food, activities, travel, objects, symbols and flags, and the picker's Groups parameter takes your own.

using System.Diagnostics.CodeAnalysis;

using Forma.Framework.Emojis;

public sealed class TeamEmojiCatalog : IEmojiCatalog
{
    private static readonly IReadOnlyList<EmojiInfo> Entries =
    [
        new() { Emoji = "🚴", Name = "person biking", Keywords = ["bicycle", "cyclist"], GroupId = "activities" },
        new() { Emoji = "🏆", Name = "trophy", Keywords = ["prize", "win"], GroupId = "activities" },
    ];

    public bool TryFindByGroupId(string groupId, out IReadOnlyList<EmojiInfo> emojis)
    {
        emojis = Entries.Where(entry => entry.GroupId == groupId).ToList();
        return emojis.Count > 0;
    }

    public bool TryGetByEmoji(Emoji emoji, [MaybeNullWhen(false)] out EmojiInfo info)
    {
        info = Entries.FirstOrDefault(entry => entry.Emoji == emoji);
        return info is not null;
    }

    public IReadOnlyList<EmojiInfo> Find(string text)
    {
        var terms = text.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);

        return terms.Length == 0
            ? []
            : Entries.Where(entry => terms.All(term => Matches(entry, term))).ToList();
    }

    private static bool Matches(EmojiInfo entry, string term)
        => entry.Name.Contains(term, StringComparison.OrdinalIgnoreCase)
            || entry.Keywords.Any(keyword => keyword.Contains(term, StringComparison.OrdinalIgnoreCase));
}
builder.Services.AddSingleton<IEmojiCatalog, TeamEmojiCatalog>();

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 (5)

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

Package Downloads
formaui-net.Framework.Emojis.Unicode

The default emoji provider for Forma.

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.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.AddOns.Emojis.Twemoji

The Twemoji artwork and emoji catalog for Forma.Blazor.

formaui-net.Blazor.Composer

FormaComposer, a rich text authoring surface for Blazor: an editor with the toolbar, dialogs, views and attachments an article or a page body needs, assembled from plugins the host picks.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.27 60 12/3/2026
1.0.0-preview.26 73 12/3/2026
1.0.0-preview.25 74 12/2/2026
1.0.0-preview.24 97 12/1/2026
1.0.0-preview.23 131 11/30/2026
1.0.0-preview.22 132 11/30/2026
1.0.0-preview.21 133 11/29/2026
1.0.0-preview.20 131 11/26/2026
1.0.0-preview.19 133 11/26/2026
1.0.0-preview.18 134 11/26/2026
1.0.0-preview.17 118 11/26/2026
1.0.0-preview.16 119 11/24/2026
1.0.0-preview.15 118 11/23/2026
1.0.0-preview.14 115 11/23/2026
1.0.0-preview.13 112 11/21/2026
1.0.0-preview.12 113 11/20/2026
1.0.0-preview.11 111 11/18/2026
1.0.0-preview.10 118 11/17/2026
1.0.0-preview.9 145 11/17/2026
1.0.0-preview.8 123 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