-
Notifications
You must be signed in to change notification settings - Fork 3
Getting Started
This guide walks you through adding icons to an Avalonia application using Optris.Icons.Avalonia.
- .NET 8, 9, or 10
- An Avalonia 12 project
Install the core package and at least one icon provider via NuGet:
dotnet add package Optris.Icons.Avalonia
dotnet add package Optris.Icons.Avalonia.FontAwesome
dotnet add package Optris.Icons.Avalonia.FontAwesome7
dotnet add package Optris.Icons.Avalonia.MaterialDesignYou only need the icon packs you plan to use. Font Awesome 6 and 7 can be used side-by-side.
Register the icon providers before building the Avalonia app, typically in Program.cs:
using Optris.Icons.Avalonia;
using Optris.Icons.Avalonia.FontAwesome;
using Optris.Icons.Avalonia.FontAwesome7;
using Optris.Icons.Avalonia.MaterialDesign;
IconProvider.Current
.Register<FontAwesomeIconProvider>()
.Register<FontAwesome7IconProvider>()
.Register<MaterialDesignIconProvider>();This tells the library which icon packs are available at runtime.
In any AXAML file where you want to use icons, add this namespace:
xmlns:i="https://github.com/projektanker/icons.avalonia"Note: This URL is an opaque XML namespace identifier, not a clickable web link. It is preserved from the original project for backward compatibility.
<i:Icon Value="fa-solid fa-check" FontSize="24" />This renders a Font Awesome solid check icon at 24px.
For Material Design:
<i:Icon Value="mdi-check" FontSize="24" />Run your app and confirm the icon renders. If you see an error about no registered provider, make sure the Register calls in Program.cs run before AppBuilder.Configure<App>().
Try the live demo to browse icons interactively.
- Usage Guide -- all the ways to use icons (controls, attached properties, images, animations)
- Icon Packs -- browse available icons and understand naming conventions
- Custom Providers -- implement your own icon source