forked from Projektanker/Icons.Avalonia
-
Notifications
You must be signed in to change notification settings - Fork 3
API Reference
Valentino Saitz edited this page Apr 9, 2026
·
2 revisions
Namespace: Optris.Icons.Avalonia
XAML namespace: xmlns:i="https://github.com/projektanker/icons.avalonia"
TemplatedControl that displays an icon.
| Property | Type | Default | Description |
|---|---|---|---|
Value |
string |
"" |
Icon identifier (e.g. "fa-solid fa-check") |
Animation |
IconAnimation |
None |
Animation mode |
FontSize |
double |
inherited | Icon size in pixels |
Foreground |
IBrush |
Black |
Icon fill color |
DrawingImage that renders an icon. Use as Image.Source.
| Property | Type | Default | Description |
|---|---|---|---|
Value |
string |
"" |
Icon identifier |
Brush |
IBrush |
Black |
Fill brush |
Pen |
IPen |
none | Stroke pen (0-width default) |
Sets an icon on any ContentControl (Button, ToggleButton, etc.). Replaces the control's Content with an Icon control.
<Button i:Attached.Icon="fa-solid fa-save" />Sets an icon on an Avalonia MenuItem.
<MenuItem Header="Open" i:MenuItem.Icon="fa-solid fa-folder-open" />| Value | Description |
|---|---|
None |
No animation (default) |
Spin |
Smooth 360-degree rotation, 2-second loop |
Pulse |
Stepped rotation (8 discrete steps), 2-second loop |
Singleton registry that routes icon requests to the correct provider.
| Member | Description |
|---|---|
static Current |
The singleton instance |
GetIcon(string value) |
Resolves an icon by prefix-matching a registered provider |
Register<T>() |
Registers a provider by type (requires parameterless constructor) |
Register(IIconProvider) |
Registers a provider instance |
public interface IIconReader
{
IconModel GetIcon(string value);
}Returns the icon model for the given value. Throws KeyNotFoundException if the icon is not found.
public interface IIconProvider : IIconReader
{
string Prefix { get; }
}Extends IIconReader with a Prefix used for routing.
public interface IIconProviderContainer
{
IIconProviderContainer Register(IIconProvider iconProvider);
IIconProviderContainer Register<TIconProvider>() where TIconProvider : IIconProvider, new();
}Registration interface. Returns this for fluent chaining.
public record IconModel(ViewBoxModel ViewBox, PathModel Path);public record ViewBoxModel(int X, int Y, int Width, int Height)
{
public static ViewBoxModel Parse(string viewBox); // parses "x y width height"
}public readonly record struct PathModel(string path);Wraps an SVG path string. Implicitly converts to string.
-
Package:
Optris.Icons.Avalonia.FontAwesome -
Prefix:
fa -
Constructors:
-
FontAwesomeIconProvider()-- uses the built-in Free icon set -
FontAwesomeIconProvider(IFontAwesomeUtf8JsonStreamProvider)-- uses a custom icon source
-
-
Package:
Optris.Icons.Avalonia.FontAwesome7 -
Prefix:
fa7 -
Constructors:
-
FontAwesome7IconProvider()-- uses the built-in Free icon set -
FontAwesome7IconProvider(IFontAwesome7Utf8JsonStreamProvider)-- uses a custom icon source
-
-
Package:
Optris.Icons.Avalonia.MaterialDesign -
Prefix:
mdi -
Constructor:
MaterialDesignIconProvider()-- loads embedded SVG assets