Generate Icon components from official ant-design-icons repo with Source Generators.
You can add all icons from https://ant.design/components/icon
-
Install package
$ dotnet add package AntDesign.Icons
-
Add
@using AntDesign.Iconsto your_Imports.razorfile -
We offer two ways to use it.
- One is the component approach, which can be placed anywhere in the razor template.
<TagTwotone TwoToneColor="@(["red","yellow"])" />
- The other is the static method approach, which returns RenderFargment that can be used as an attribute value or as a variable.
@AlertTwotone.RenderIcon(twoToneColor:["#52c41a", "#398439"])They have the same parameters and achieve the same functionality.
| Property | Description | Type | Default Value |
|---|---|---|---|
| Class | class Name of Icon | string | - |
| Style | Style properties of icon, like fontSize and color | string | |
| Spin | Rotate icon with animation | boolean | - |
| Rotate | Rotate by n degrees | int | - |
| TwoToneColor | Only supports the two-tone icon. Specify the primary color. | string[] | - |
- Install the .NET Compiler Platform SDK with VS2022 for debug the Source Generators.
- Set
AntDesign.Icons.Generatoras startup project. - Press F5 or click
Debugbutton on top of VS2022.