Soenneker.Blazor.SignaturePads
11.0.244
Prefix Reserved
dotnet add package Soenneker.Blazor.SignaturePads --version 11.0.244
NuGet\Install-Package Soenneker.Blazor.SignaturePads -Version 11.0.244
<PackageReference Include="Soenneker.Blazor.SignaturePads" Version="11.0.244" />
<PackageVersion Include="Soenneker.Blazor.SignaturePads" Version="11.0.244" />
<PackageReference Include="Soenneker.Blazor.SignaturePads" />
paket add Soenneker.Blazor.SignaturePads --version 11.0.244
#r "nuget: Soenneker.Blazor.SignaturePads, 11.0.244"
#:package Soenneker.Blazor.SignaturePads@11.0.244
#addin nuget:?package=Soenneker.Blazor.SignaturePads&version=11.0.244
#tool nuget:?package=Soenneker.Blazor.SignaturePads&version=11.0.244
Soenneker.Blazor.SignaturePads
A Blazor component and JS interop wrapper for drawing, restoring, and exporting signatures with signature_pad.
Installation
dotnet add package Soenneker.Blazor.SignaturePads
Register the interop service in Program.cs:
using Soenneker.Blazor.SignaturePads.Registrars;
builder.Services.AddSignaturePadAsScoped();
Add the component namespace to _Imports.razor:
@using Soenneker.Blazor.SignaturePads
Basic usage
Give the canvas an explicit rendered size, wait for OnReady, and use the component reference for operations:
@using Soenneker.Blazor.SignaturePads.Configuration
<SignaturePadCanvas @ref="_signaturePad"
Style="width: 100%; height: 220px; border: 1px solid #bbb;"
Options="_options"
OnReady="HandleReady"
aria-label="Signature input" />
<button type="button" disabled="@(!_ready)" @onclick="ClearAsync">Clear</button>
<button type="button" disabled="@(!_ready)" @onclick="ExportAsync">Export PNG</button>
@if (_png is not null)
{
<img src="@_png" alt="Signature preview" />
}
@code {
private SignaturePadCanvas? _signaturePad;
private bool _ready;
private string? _png;
private readonly SignaturePadOptions _options = new()
{
PenColor = "#111827",
BackgroundColor = "rgb(255,255,255)",
MinWidth = 0.8,
MaxWidth = 2.2
};
private void HandleReady() => _ready = true;
private async Task ClearAsync() => await _signaturePad!.Clear();
private async Task ExportAsync()
{
if (!await _signaturePad!.IsEmpty())
_png = await _signaturePad.ToDataUrl("image/png");
}
}
Public component methods throw until the canvas has completed its first interactive render. OnReady is the safest point to enable controls that call them.
Saving and restoring signatures
Choose the representation based on what you need later:
// Editable stroke data: best for restoring and continuing to draw.
IReadOnlyList<SignaturePadPointGroup> strokes = await _signaturePad.ToData();
await _signaturePad.FromData(strokes);
// Raster output for display or upload.
string pngDataUrl = await _signaturePad.ToDataUrl("image/png");
// Generated SVG markup.
string svg = await _signaturePad.ToSvg();
FromData(data, clear: true) replaces existing strokes by default. Pass clear: false to append them. FromDataUrl() draws an image onto the canvas; it does not recreate editable stroke groups.
Data URLs contain a media-type prefix and Base64 payload. If an API expects bytes, remove the prefix and decode the payload before upload. Do not store large data URLs in normal form fields or logs.
Resizing
ObserveResize defaults to true and scales the canvas backing buffer for the device pixel ratio. The canvas still needs a non-zero CSS width and height from your layout.
With PreserveDrawingOnResize="true", existing point data is redrawn after a resize. Points retain their original canvas coordinates; changing the aspect ratio or making the canvas substantially smaller can clip or reposition the visible signature. Set it to false when a resize should clear the pad.
Options and controls
SignaturePadOptions configures dot size, minimum and maximum line width, throttling, minimum point distance, background color, pen color, velocity filtering, and canvas compositing. Updated option values are applied after subsequent component renders, or immediately through SetOptions().
The component also exposes:
Clear()andIsEmpty();Enable()andDisable()for pointer listeners;ToData(),ToDataUrl(), andToSvg()for export;FromData(),FromDataUrl(), andRedraw()for restoration.
Security and accessibility
- Signatures are sensitive personal data. Protect them in transit and storage, restrict access, and define retention rules appropriate to your application.
- Loading a remote image with
FromDataUrl()can taint the canvas when the image server does not permit cross-origin use. A tainted canvas cannot be exported to PNG or SVG data successfully. ToSvg()returns markup. If you insert it as raw HTML, sanitize it according to your application's trust boundary; rendering it through an<img>data URL avoids direct DOM injection.- A canvas is not an accessible substitute for consent or identity verification. Provide instructions, an accessible name, keyboard-operable controls, and an alternative completion method.
The package loads pinned signature_pad JavaScript from jsDelivr with subresource integrity validation. Applications that disallow third-party scripts must account for that origin in their Content Security Policy or provide an approved asset-loading strategy.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Asyncs.Initializers (>= 11.0.140)
- Soenneker.Blazor.Extensions.IJSObjectReferences (>= 11.0.6)
- Soenneker.Blazor.Utils.ResourceLoader (>= 11.0.1840)
- Soenneker.Lepton.Suite (>= 11.0.144)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Blazor.SignaturePads:
| Package | Downloads |
|---|---|
|
Soenneker.Quark.Suite
Shadcn-powered Blazor UI, refined and modular. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.244 | 0 | 11/15/2026 |
| 11.0.243 | 0 | 11/15/2026 |
| 11.0.242 | 45 | 11/14/2026 |
| 11.0.241 | 45 | 11/14/2026 |
| 11.0.240 | 47 | 11/14/2026 |
| 11.0.239 | 1,032 | 11/12/2026 |
| 11.0.238 | 73 | 11/12/2026 |
| 11.0.237 | 163 | 11/12/2026 |
| 11.0.236 | 166 | 11/12/2026 |
| 11.0.235 | 183 | 11/11/2026 |
| 11.0.234 | 180 | 11/11/2026 |
| 11.0.232 | 349 | 11/11/2026 |
| 11.0.231 | 110 | 11/11/2026 |
| 11.0.230 | 129 | 11/11/2026 |
| 11.0.229 | 149 | 11/11/2026 |
| 11.0.227 | 228 | 11/11/2026 |
| 11.0.226 | 70 | 11/11/2026 |
| 11.0.224 | 2,691 | 11/4/2026 |
| 11.0.223 | 369 | 11/3/2026 |
| 11.0.222 | 142 | 11/3/2026 |
Update dependency Soenneker.Blazor.Utils.ResourceLoader to 11.0.1840 (#840)