Soenneker.Blazor.Utils.Clipboard
4.0.36
Prefix Reserved
dotnet add package Soenneker.Blazor.Utils.Clipboard --version 4.0.36
NuGet\Install-Package Soenneker.Blazor.Utils.Clipboard -Version 4.0.36
<PackageReference Include="Soenneker.Blazor.Utils.Clipboard" Version="4.0.36" />
<PackageVersion Include="Soenneker.Blazor.Utils.Clipboard" Version="4.0.36" />
<PackageReference Include="Soenneker.Blazor.Utils.Clipboard" />
paket add Soenneker.Blazor.Utils.Clipboard --version 4.0.36
#r "nuget: Soenneker.Blazor.Utils.Clipboard, 4.0.36"
#:package Soenneker.Blazor.Utils.Clipboard@4.0.36
#addin nuget:?package=Soenneker.Blazor.Utils.Clipboard&version=4.0.36
#tool nuget:?package=Soenneker.Blazor.Utils.Clipboard&version=4.0.36
Soenneker.Blazor.Utils.Clipboard
Blazor library for reading and writing the clipboard in the browser. Uses the Clipboard API (HTTPS or localhost). Supports plain text, HTML, images, permission checks, and no-throw helpers.
Install
dotnet add package Soenneker.Blazor.Utils.Clipboard
Setup
Register clipboard services (e.g. in Program.cs):
builder.Services.AddClipboardAsScoped();
Inject IClipboardUtil where you need it:
@inject IClipboardUtil Clipboard
Usage
Check if clipboard is available
Use this when you might not be in a secure context (e.g. prerender, some hosts). Result is cached.
if (await Clipboard.HasClipboard())
{
await Clipboard.CopyText("Hello");
}
Read and write plain text
// Write
await Clipboard.WriteText("Hello, world");
await Clipboard.CopyText("Same as WriteText"); // alias
// Read (may throw if permission denied)
string text = await Clipboard.ReadText();
Try read / try write (no throw)
Use these to avoid try/catch when you only care about success or failure:
// Try read: (success, text)
var (ok, text) = await Clipboard.TryReadText();
if (ok && !string.IsNullOrEmpty(text))
Console.WriteLine(text);
// Try write: true if copied, false on error
bool copied = await Clipboard.TryWriteText("Hello");
if (!copied)
ShowMessage("Could not copy to clipboard");
Permission state
Check read/write permission state (where supported; returns Unsupported in e.g. Firefox/Safari):
var readState = await Clipboard.GetReadPermissionState(); // Granted, Denied, Prompt, Unsupported
var writeState = await Clipboard.GetWritePermissionState();
Clear clipboard
await Clipboard.Clear();
Rich content: plain + HTML
Useful when pasting into rich editors (plain fallback + HTML):
await Clipboard.CopyPlainAndHtml("Fallback text", "<p>Rich <b>HTML</b></p>");
Read/write multiple types (text, HTML, images)
For full control, use Read() and Write() with ClipboardItemDto. Each item has a dictionary of MIME type → content (text or data URL for images).
// Read all items and types from clipboard
IReadOnlyList<ClipboardItemDto> items = await Clipboard.Read();
foreach (var item in items)
{
foreach (var (mimeType, content) in item.Types)
{
if (content.StartsWith("data:image/"))
// image as data URL
else
// text (e.g. text/plain, text/html)
}
}
// Write custom items
await Clipboard.Write(new[]
{
ClipboardItems.CreatePlainAndHtml("Plain", "<p>HTML</p>"),
ClipboardItems.CreateImage("data:image/png;base64,...")
});
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.9)
- Soenneker.Blazor.Utils.ModuleImport (>= 4.0.1822)
- Soenneker.Utils.AsyncSingleton (>= 4.0.802)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Blazor.Utils.Clipboard:
| 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 |
|---|---|---|
| 4.0.36 | 0 | 6/19/2026 |
| 4.0.35 | 0 | 6/19/2026 |
| 4.0.34 | 5 | 6/18/2026 |
| 4.0.33 | 404 | 6/17/2026 |
| 4.0.32 | 89 | 6/16/2026 |
| 4.0.31 | 2,147 | 6/10/2026 |
| 4.0.30 | 281 | 6/10/2026 |
| 4.0.29 | 207 | 6/10/2026 |
| 4.0.28 | 1,609 | 6/7/2026 |
| 4.0.27 | 90 | 6/6/2026 |
| 4.0.26 | 92 | 6/6/2026 |
| 4.0.25 | 94 | 6/6/2026 |
| 4.0.24 | 1,774 | 6/5/2026 |
| 4.0.23 | 94 | 6/5/2026 |
| 4.0.22 | 4,091 | 5/13/2026 |
| 4.0.21 | 584 | 5/12/2026 |
| 4.0.20 | 1,603 | 5/2/2026 |
| 4.0.19 | 120 | 4/25/2026 |
| 4.0.18 | 105 | 4/24/2026 |
| 4.0.17 | 102 | 4/24/2026 |