Projektanker.Icons.Avalonia.FontAwesome
9.4.1
dotnet add package Projektanker.Icons.Avalonia.FontAwesome --version 9.4.1
NuGet\Install-Package Projektanker.Icons.Avalonia.FontAwesome -Version 9.4.1
<PackageReference Include="Projektanker.Icons.Avalonia.FontAwesome" Version="9.4.1" />
paket add Projektanker.Icons.Avalonia.FontAwesome --version 9.4.1
#r "nuget: Projektanker.Icons.Avalonia.FontAwesome, 9.4.1"
// Install Projektanker.Icons.Avalonia.FontAwesome as a Cake Addin #addin nuget:?package=Projektanker.Icons.Avalonia.FontAwesome&version=9.4.1 // Install Projektanker.Icons.Avalonia.FontAwesome as a Cake Tool #tool nuget:?package=Projektanker.Icons.Avalonia.FontAwesome&version=9.4.1
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 project.
1. Register icon providers on app start up
Register the icon provider(s) with the IconProvider.Current
.
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()
{
IconProvider.Current
.Register<FontAwesomeIconProvider>()
.Register<MaterialDesignIconProvider>();
return AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace();
}
}
2. Add xml namespace
Add xmlns:i="https://github.com/projektanker/icons.avalonia"
to your view.
3. Use the icon
Standalone
<i:Icon Value="fa-brands fa-anchor" />
Attached to ContentControl (e.g. Button)
<Button i:Attached.Icon="fa-brands fa-anchor" />
Attached to MenuItem
<MenuItem Header="About" i:MenuItem.Icon="fa-solid fa-circle-info" />
Custom icon size
<i:Icon Value="fa-brands fa-anchor" FontSize="24" />
Animated
<i:Icon Value="fa-spinner" Animation="Pulse" />
<i:Icon Value="fa-sync" Animation="Spin" />
As an Image source
<Image>
<Image.Source>
<i:IconImage Value="fa-brands fa-anchor" Brush="(defaults to black)" />
</Image.Source>
</Image>
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 model of the requested icon.
/// </summary>
/// <param name="value">The value specifying the icon to return it's model from.</param>
/// <returns>The model of the icon.</returns>
/// <exception cref="System.Collections.Generic.KeyNotFoundException">
/// The icon associated with the specified <paramref name="value"/> does not exists.
/// </exception>
IconModel GetIcon(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
:
IconProvider.Current.Register<MyCustomIconProvider>()
or
IIconProvider provider = new MyCustomIconProvider(/* custom ctor arguments */);
IconProvider.Current.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
.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Projektanker.Icons.Avalonia (>= 9.4.1)
- System.Text.Json (>= 8.0.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Projektanker.Icons.Avalonia.FontAwesome:
Package | Downloads |
---|---|
AvaloniaXT
Avalonia App Page Helper Dll , Contains MainWindow,SukiUI,Support AOT |
GitHub repositories (12)
Showing the top 5 popular GitHub repositories that depend on Projektanker.Icons.Avalonia.FontAwesome:
Repository | Stars |
---|---|
LykosAI/StabilityMatrix
Multi-Platform Package Manager for Stable Diffusion
|
|
GreemDev/Ryujinx
Experimental Switch emulator written in C#
|
|
sn4k3/UVtools
MSLA/DLP, file analysis, calibration, repair, conversion and manipulation
|
|
aloneguid/parquet-dotnet
Fully managed Apache Parquet implementation
|
|
fifty-six/Scarab
An installer for Hollow Knight mods written in Avalonia.
|
Version | Downloads | Last updated | |
---|---|---|---|
9.4.1 | 1,876 | 10/4/2024 | |
9.4.0 | 11,014 | 7/21/2024 | |
9.3.0 | 9,679 | 4/7/2024 | |
9.2.0 | 867 | 3/29/2024 | |
9.1.2 | 1,614 | 3/12/2024 | |
9.1.1 | 5,144 | 2/22/2024 | |
9.0.1 | 7,742 | 12/8/2023 | |
9.0.0 | 581 | 12/6/2023 | |
8.4.0 | 2,334 | 12/6/2023 | |
8.3.0 | 7,327 | 10/11/2023 | |
8.2.0 | 4,670 | 8/6/2023 | |
8.1.0 | 999 | 7/26/2023 | |
8.0.0 | 1,186 | 7/17/2023 | |
7.0.1 | 1,137 | 7/16/2023 | |
7.0.0 | 690 | 7/16/2023 | |
6.6.0 | 1,796 | 7/10/2023 | |
6.6.0-rc1.1 | 1,542 | 6/7/2023 | |
6.6.0-preview6 | 952 | 4/26/2023 | |
6.5.0-preview6 | 950 | 3/24/2023 | |
6.5.0-preview5 | 777 | 2/28/2023 | |
6.4.0-preview5 | 787 | 2/4/2023 | |
6.3.0-preview4 | 984 | 12/12/2022 | |
6.2.0-preview1 | 771 | 9/21/2022 | |
6.1.0-preview1 | 610 | 8/29/2022 | |
6.0.0-preview1 | 652 | 8/24/2022 | |
5.13.0 | 3,754 | 4/26/2023 | |
5.12.0 | 1,282 | 4/2/2023 | |
5.11.0 | 989 | 3/26/2023 | |
5.10.0 | 1,337 | 2/28/2023 | |
5.9.0 | 1,578 | 2/12/2023 | |
5.8.0 | 1,934 | 12/12/2022 | |
5.7.0 | 781 | 12/12/2022 | |
5.6.0 | 2,739 | 11/20/2022 | |
5.5.0 | 11,130 | 9/4/2022 | |
5.4.0 | 968 | 8/29/2022 | |
5.3.0 | 2,151 | 7/31/2022 | |
5.2.0 | 1,117 | 7/24/2022 | |
5.1.0 | 2,517 | 7/3/2022 | |
5.0.2 | 1,775 | 5/27/2022 | |
5.0.1 | 1,169 | 5/23/2022 | |
5.0.0 | 973 | 5/23/2022 | |
4.5.0 | 886 | 5/22/2022 | |
4.4.0 | 2,646 | 4/3/2022 | |
4.3.0 | 1,036 | 3/27/2022 | |
4.2.1 | 1,245 | 3/16/2022 | |
4.2.0 | 974 | 3/14/2022 | |
4.1.0 | 1,122 | 3/9/2022 | |
4.0.1 | 928 | 3/8/2022 | |
4.0.0 | 967 | 3/7/2022 | |
3.7.1 | 2,247 | 12/15/2021 | |
3.7.0 | 2,223 | 11/20/2021 | |
3.5.0 | 909 | 11/12/2021 | |
3.4.1 | 1,283 | 11/8/2021 | |
3.4.0 | 834 | 11/8/2021 | |
3.2.0 | 1,151 | 10/17/2021 | |
3.1.4 | 949 | 10/14/2021 | |
3.1.2 | 2,188 | 8/13/2021 | |
3.1.1 | 926 | 8/11/2021 | |
3.1.0 | 1,730 | 3/22/2021 | |
3.0.0-pre | 1,325 | 10/29/2020 | |
2.0.2 | 1,242 | 8/12/2020 | |
2.0.1 | 1,198 | 7/27/2020 | |
2.0.0 | 1,145 | 7/27/2020 | |
1.1.0 | 1,105 | 7/27/2020 | |
1.0.0 | 1,153 | 7/27/2020 |