SvgBlazor is a simple library that allows you to write C# code that is transformed directly into svg elements. Thanks to its simple, yet powerful API, you can easily compose beautiful svg drawings.
To install SvgBlazor use NuGet Package Manager or install it with the following command:
dotnet add package SvgBlazor
Once the installation is complete, add SvgBlazor in _Imports.razor:
@using SvgBlazor
Add a SvgComponent tag in your .razor file and capture it's reference by using @ref property:
<SvgComponent Width="200" Height="200" @ref="svgComponent" />
@code {
private SvgComponent svgComponent;
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
var circle = new SvgCircle
{
CenterX = 100,
CenterY = 100,
Radius = 100,
Fill = new SvgFill
{
Color = "#FF2800",
},
};
svgComponent.Add(circle);
}
}
}
This software is released under the MIT license.