百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
B

Blazor.SVGEditor

> 开发工具
开源

一个基于 Blazor 编写的基本 SVG 编辑器。

337 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个基于 Blazor 编写的基本 SVG 编辑器。

KristofferStrube.Blazor.SVGEditor

A basic HTML SVG Editor written in Blazor.

Demo

The WASM sample project can be demoed at https://kristofferstrube.github.io/Blazor.SVGEditor/

Getting Started

Prerequisites

You need to install .NET 7.0 or newer to use the library.

Download .NET 7

Installation

You can install the package via NuGet with the Package Manager in your IDE or alternatively using the command line:

bash
dotnet add package KristofferStrube.Blazor.SVGEditor

The package can be used in Blazor WebAssembly and Blazor Server projects. In the samples folder of this repository, you can find two projects that show how to use the SVGEditor component in both Blazor Server and WASM.

Import

You need to reference the package to use it in your pages. This can be done in _Import.razor by adding the following.

razor
@using KristofferStrube.Blazor.SVGEditor

Add to service collection

To use the component in your pages you also need to register som services in your service collection. We have made a single method that allows you to add the needed service which you use like so:

csharp
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add("#app");
builder.RootComponents.Add("head::after");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

// Adding the needed services.
builder.Services.AddSVGEditor();

await builder.Build().RunAsync();

Include needed stylesheets and scripts

The libraries that the component uses also need to have some stylesheets and scripts added to function. For this, you need to insert the following tags in the `` section of your index.html or Host.cshtml file:

xml

The library uses Scoped CSS, so you must include your project-specific .styles.css CSS file in your project for the scoped styles of the library components. An example is in the test project in this repo:

xml

At the end of the file, after you have referenced the Blazor Server or Wasm bootstrapper, insert the following:

xml

Adding the component to a site.

Now, you are ready to use the component in your page. A minimal example of this would be the following:

razor

@code {
    private string Input = @"";
}

Tag type support and attributes

  • RECT (x, y, width, height, fill, stroke, stroke-width, stroke-linecap, stroke-linejoin, stroke-offset)
  • CIRCLE (cx, cy, r, fill, stroke, stroke-width, stroke-linecap, stroke-linejoin, stroke-offset)
  • ELLIPSE (cx, cy, rx, ry, fill, stroke, stroke-width, stroke-linecap, stroke-linejoin, stroke-offset)
  • POLYGON (points, fill, stroke, stroke-width, stroke-linecap, stroke-linejoin, stroke-offset)
  • POLYLINE (points, fill, stroke, stroke-width, stroke-linecap, stroke-linejoin, stroke-offset)
  • LINE (x1, y1, x2, y2, fill, stroke, stroke-width, stroke-linecap, stroke-linejoin, stroke-offset)
  • TEXT (x, y, style:(font-size,font-weight,font-family), fill, stroke, stroke-width, stroke-linecap, stroke-linejoin, stroke-offset)
  • PATH (d, fill, stroke, stroke-width, stroke-linecap, stroke-linejoin, stroke-offset)
    • Movements
    • Lines
    • Vertical Lines
    • Horizontal Lines
    • Close Path
    • Cubic Bézier Curve
      • Shorthand aswell
    • Quadratic Bézier Curve
      • Shorthand aswell
    • Elliptical Arc Curve
      • Needs more work for radi interaction
  • G (fill, stroke, stroke-width, stroke-linecap, stroke-linejoin, stroke-offset)
    • Missing scaling of children
  • ANIMATE
    • Support for showing all Animate tags when Playing
    • Support for editing Fill animation values
    • Support for editing Stroke animation values
    • Support for editing Stroke Offset values
  • LINEARGRADIENT (x1, x2, y1, y2, and stops)

Current goals

  • Add support for touch devices
  • Support errors better to recover instead of crashing when parsing malformed SVGs.

Issues

Feel free to open issues on the repository if you find any errors with the package or have wishes for features.

Related articles:

  • https://kristoffer-strube.dk/post/blazor-svgeditor-released/

Diagram of relation between core types in the project.

…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#blazorblazor-webassemblydrag-and-dropeditor

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具