![]() |
VOOZH | about |
dotnet add package Soenneker.Blazor.Utils.Clipboard --version 4.0.34
NuGet\Install-Package Soenneker.Blazor.Utils.Clipboard -Version 4.0.34
<PackageReference Include="Soenneker.Blazor.Utils.Clipboard" Version="4.0.34" />
<PackageVersion Include="Soenneker.Blazor.Utils.Clipboard" Version="4.0.34" />Directory.Packages.props
<PackageReference Include="Soenneker.Blazor.Utils.Clipboard" />Project file
paket add Soenneker.Blazor.Utils.Clipboard --version 4.0.34
#r "nuget: Soenneker.Blazor.Utils.Clipboard, 4.0.34"
#:package Soenneker.Blazor.Utils.Clipboard@4.0.34
#addin nuget:?package=Soenneker.Blazor.Utils.Clipboard&version=4.0.34Install as a Cake Addin
#tool nuget:?package=Soenneker.Blazor.Utils.Clipboard&version=4.0.34Install as a Cake Tool
👁 alternate text is missing from this package README image
👁 alternate text is missing from this package README image
👁 alternate text is missing from this package README image
👁 alternate text is missing from this package README image
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.
dotnet add package Soenneker.Blazor.Utils.Clipboard
Register clipboard services (e.g. in Program.cs):
builder.Services.AddClipboardAsScoped();
Inject IClipboardUtil where you need it:
@inject IClipboardUtil Clipboard
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");
}
// Write
await Clipboard.WriteText("Hello, world");
await Clipboard.CopyText("Same as WriteText"); // alias
// Read (may throw if permission denied)
string text = await Clipboard.ReadText();
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");
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();
await Clipboard.Clear();
Useful when pasting into rich editors (plain fallback + HTML):
await Clipboard.CopyPlainAndHtml("Fallback text", "<p>Rich <b>HTML</b></p>");
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 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
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. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 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 |
| 4.0.16 | 109 | 4/23/2026 |
| 4.0.15 | 107 | 4/22/2026 |