Parsed icons set from materialdesignicons.com and display control implementations for different GUI frameworks.
- All icons are always up-to-date because automatically updated every 6 hours.
- Small package size because icons are graphically encoded via SVG Path.
- Icon types are strongly typed enum, so your IDE will suggest available variants:
This project consists of 3 parts:
-
FAQ - frequently asked questions
contains controls for WinUI/UNO (separate repository)
- Install Material.Icons.Avalonia nuget package:
dotnet add package Material.Icons.Avalonia
- Include styles in
App.xaml
(for2.0.0
version and higher):<Application xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" ...> <Application.Styles> ... <materialIcons:MaterialIconStyles /> </Application.Styles> </Application>
Add Material.Icons.Avalonia
namespace to the root element of your file (your IDE can suggest it or do it automatically):
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
Use MaterialIcon
control:
<materialIcons:MaterialIcon Kind="Abacus" />
The Foreground
property controls the color of the icon.
Also, there is MaterialIconExt
which allows you to use is as the markup extension:
<Button Content="{materialIcons:MaterialIconExt Kind=Abacus}" />
Or with a text via MaterialIconTextExt
:
<Button Content="{materialIcons:MaterialIconTextExt Kind=Play, Text=Play}" />
The MaterialIcon
implements IImage
interface, to allow to use as an Image
source:
<!-- Verbose raw method -->
<Image>
<materialIcons:MaterialIcon Foreground="DeepPink" Kind="Abacus" />
</Image>
<!-- Short extension method -->
<Image Source="{materialIcons:MaterialIconExt Kind=Abacus, IconForeground=DeepPink}" />
Note that when using MaterialIcon
as an Image
source, the Width
and Height
properties must be defined under <Image>
,
any size definition on MaterialIcon
have no impact. Also, animation are not supported in this use case.
- Install Material.Icons.Avalonia nuget package:
dotnet add package Material.Icons.Avalonia
- Import styles in Application (or if you use XAML check instructions for plain Avalonia)
type App() = inherit Application() override this.Initialize() = .. this.Styles.Add(MaterialIconStyles(null)) ..
- Create bindings for
MaterialIcon
namespace Avalonia.FuncUI.DSL [<AutoOpen>] module MaterialIcon = open Material.Icons open Material.Icons.Avalonia open Avalonia.FuncUI.Types open Avalonia.FuncUI.Builder let create (attrs: IAttr<MaterialIcon> list): IView<MaterialIcon> = ViewBuilder.Create<MaterialIcon>(attrs) type MaterialIcon with static member kind<'t when 't :> MaterialIcon>(value: MaterialIconKind) : IAttr<'t> = AttrBuilder<'t>.CreateProperty<MaterialIconKind>(MaterialIcon.KindProperty, value, ValueNone)
- Use
Button.create [ Button.content ( MaterialIcon.create [ MaterialIcon.kind MaterialIconKind.Export ] ) ]
Install Material.Icons.WPF nuget package:
dotnet add package Material.Icons.WPF
Add Material.Icons.WPF
namespace to the root element of your file (your IDE can suggest it or do it automatically):
xmlns:materialIcons="clr-namespace:Material.Icons.WPF;assembly=Material.Icons.WPF"
Use MaterialIcon
control:
<materialIcons:MaterialIcon Kind="Abacus" />
The Foreground
property controls the color of the icon.
Also, there is MaterialIconExt
which allows you to use is as the markup extension:
<Button Content="{materialIcons:MaterialIconExt Kind=Abacus}" />
Install Material.Icons.WinUI3 nuget package:
dotnet add package Material.Icons.WinUI3
Add Material.Icons.WinUI3
namespace to the root element of your file (your IDE can suggest it or do it automatically):
xmlns:materialIcons="using:Material.Icons.WinUI3"
Use MaterialIcon
control:
<materialIcons:MaterialIcon Kind="Abacus" />
The Foreground
property controls the color of the icon.
Also, there is MaterialIconExt
which allows you to use is as the markup extension:
<Button Content="{materialIcons:MaterialIconExt Kind=Abacus}" />
Install Material.Icons nuget package:
dotnet add package Material.Icons
Icon types stored in Material.Icons.MaterialIconKind
enum.
We can resolve an icon path by using Material.Icons.MaterialIconDataProvider.GetData()
.
Currently, there is no way to add your own icons, as icons are enum and cannot be modified.
But you can override some existing icons to use your own data:
public class CustomIconProvider : MaterialIconDataProvider
{
public override string ProvideData(MaterialIconKind kind)
{
return kind switch
{
MaterialIconKind.TrophyVariant => "some SVG code",
_ => base.ProvideData(kind)
};
}
}
// When your application starts (e.g. in the Main method) replace MaterialIconDataProvider with your own
public static int Main(string[] args)
{
MaterialIconDataProvider.Instance = new CustomIconProvider(); // Settings custom provider
// Application startup code
// return BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}
MaterialIcon
and it extensions supports pre-defined animations:
- None
- Spin (Circular spinning)
- SpinCcw (Circular spinning in CCW)
- Pulse (Step circular spinning)
- PulseCcw (Step circular spinning in CCW)
- FadeOutIn (Fade out and in)
- FadeInOut (Fade in and out)
<MaterialIcons:MaterialIcon Kind="Refresh" Animation="Spin" />
<MaterialIcons:MaterialIcon Kind="Heart" Foreground="DeepPink" Animation="FadeInOut" />
- Change
Foreground
property.
- If you are using
MaterialIcon
control - useWidth
or/andHeight
properties. - If you are using
MaterialIconExt
- useSize
property.
- You can manually set
Material.Icons
package version in your project file.
- We use semver.
Any package with identical major and minor versions is compatible.
For example,1.0.0
and1.0.1
are compatible, but1.0.0
and1.1.0
might not be.