Projektanker.Icons.Avalonia 6.5.0-preview6
Icons.Avalonia
A library to easily display icons in an Avalonia App.
NuGet
| Name | Description | Version |
|---|---|---|
| Projektanker.Icons.Avalonia | Core library | |
| Projektanker.Icons.Avalonia.FontAwesome | Font Awesome 6 Free | |
| Projektanker.Icons.Avalonia.MaterialDesign | Material Design Icons |
Icon providers
| Name | Prefix | Example |
|---|---|---|
| FontAwesome 6 | fa |
fa-github |
| MaterialDesign | mdi |
mdi-github |
Usage
A full example is available in the demo directory.
1. Register icon providers on app start up
Register the icon provider(s) with the AppBuilder.
class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
public static void Main(string[] args)
{
BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
}
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
{
return AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace()
.WithIcons(container => container
.Register<FontAwesomeIconProvider>()
.Register<MaterialDesignIconProvider>());
}
}
2. Add xml namespace
Add xmlns:i="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia" to your view.
3. Use the icon
Standalone
<i:Icon Value="fa-brands fa-github" />
Attached to ContentControl (e.g. Button)
<Button i:Attached.Icon="fa-brands fa-github" />
Attached to MenuItem
<MenuItem Header="About" i:MenuItem.Icon="fa-solid fa-circle-info" />
Animated
⚠️ There is currently a bug in Avalonia 11: https://github.com/AvaloniaUI/Avalonia/issues/8791
<i:Icon Value="fa-spinner" Animation="Pulse" />
<i:Icon Value="fa-sync" Animation="Spin" />
Done

Implement your own Icon Provider
Just implement the IIconProvider interface:
namespace Projektanker.Icons.Avalonia
{
/// <summary>
/// Represents an icon reader.
/// </summary>
public interface IIconReader
{
/// <summary>
/// Gets the SVG path of the requested icon.
/// </summary>
/// <param name="value">The value specifying the icon to return it's path from.</param>
/// <returns>The path of the icon.</returns>
/// <exception cref="System.Collections.Generic.KeyNotFoundException">
/// The icon associated with the specified <paramref name="value"/> does not exists.
/// </exception>
string GetIconPath(string value);
}
/// <summary>
/// Represents an icon provider.
/// </summary>
public interface IIconProvider : IIconReader
{
/// <summary>
/// Gets the prefix of the <see cref="IIconProvider"/>.
/// </summary>
string Prefix { get; }
}
}
and register it with the IIconProviderContainer:
container.Register<MyCustomIconProvider>()
or
IIconProvider provider = new MyCustomIconProvider(/* custom ctor arguments */);
container.Register(provider);
The IIconProvider.Prefix property has to be unique within all registered providers. It is used to select the right provider. E.g. FontAwesomeIconProvider's prefix is fa.
Showing the top 20 packages that depend on Projektanker.Icons.Avalonia.
| Packages |
|---|
|
Projektanker.Icons.Avalonia.FontAwesome
A library to easily display FontAwesome icons in an Avalonia App.
|
.NET Standard 2.0
- Avalonia (>= 11.0.0-preview6)
- System.Reactive.Linq (>= 5.0.0)
| Version | Last updated |
|---|---|
| 9.6.2 | 5/16/2025 |
| 9.6.1 | 3/19/2025 |
| 9.6.0 | 6/27/2025 |
| 9.5.0 | 4/23/2025 |
| 9.4.3 | 4/26/2025 |
| 9.4.2 | 3/16/2025 |
| 9.4.1 | 5/21/2025 |
| 9.4.0 | 4/12/2025 |
| 9.3.0 | 4/12/2025 |
| 9.2.0 | 4/12/2025 |
| 9.1.2 | 4/12/2025 |
| 9.1.1 | 4/12/2025 |
| 9.0.1 | 4/12/2025 |
| 9.0.0 | 4/12/2025 |
| 8.4.0 | 4/12/2025 |
| 8.3.0 | 4/10/2025 |
| 8.2.0 | 4/12/2025 |
| 8.1.0 | 4/12/2025 |
| 8.0.0 | 4/12/2025 |
| 7.0.1 | 4/12/2025 |
| 7.0.0 | 4/12/2025 |
| 6.6.0 | 4/12/2025 |
| 6.6.0-rc1.1 | 4/12/2025 |
| 6.6.0-preview6 | 4/12/2025 |
| 6.5.0-preview6 | 4/11/2025 |
| 6.5.0-preview5 | 4/11/2025 |
| 6.4.0-preview5 | 4/11/2025 |
| 6.3.0-preview4 | 4/12/2025 |
| 6.2.0-preview1 | 4/11/2025 |
| 6.1.0-preview1 | 4/11/2025 |
| 6.0.0-preview1 | 4/12/2025 |
| 5.13.0 | 4/12/2025 |
| 5.12.0 | 4/12/2025 |
| 5.11.0 | 4/12/2025 |
| 5.10.0 | 4/12/2025 |
| 5.9.0 | 4/12/2025 |
| 5.8.0 | 4/12/2025 |
| 5.7.0 | 4/12/2025 |
| 5.6.0 | 4/12/2025 |
| 5.5.0 | 4/12/2025 |
| 5.4.0 | 4/12/2025 |
| 5.3.0 | 4/12/2025 |
| 5.2.0 | 4/12/2025 |
| 5.1.0 | 4/12/2025 |
| 5.0.2 | 4/12/2025 |
| 5.0.1 | 4/12/2025 |
| 5.0.0 | 4/12/2025 |
| 4.5.0 | 4/12/2025 |
| 4.4.0 | 4/12/2025 |
| 4.3.0 | 4/12/2025 |
| 4.2.1 | 4/12/2025 |
| 4.2.0 | 4/12/2025 |
| 4.1.0 | 4/12/2025 |
| 4.0.1 | 4/12/2025 |
| 4.0.0 | 4/12/2025 |
| 3.7.1 | 3/31/2025 |
| 3.7.0 | 4/12/2025 |
| 3.5.0 | 4/8/2025 |
| 3.4.1 | 4/12/2025 |
| 3.4.0 | 4/12/2025 |
| 3.2.0 | 4/12/2025 |
| 3.1.4 | 4/12/2025 |
| 3.1.2 | 4/12/2025 |
| 3.1.1 | 4/12/2025 |
| 3.1.0 | 4/11/2025 |
| 3.1.0-pre | 4/12/2025 |
| 3.0.0 | 4/12/2025 |
| 3.0.0-pre | 4/11/2025 |
| 2.0.2 | 4/12/2025 |
| 2.0.1 | 4/12/2025 |
| 2.0.0 | 4/2/2025 |
| 1.0.0 | 4/9/2025 |