CurrieTechnologies.Razor.Clipboard 1.5.0
CurrieTechnologies.Razor.Clipboard
This package provides Blazor applications with access to the browser's Clipboard API
This package is for Blazor Server Apps and Blazor WebAssembly Apps. It should be used instead of CurrieTechnologies.Blazor.Clipboard which is now deprecated.
Usage
In your Blazor app, add the
CurrieTechnologies.Razor.ClipboardNuGet packageInstall-Package CurrieTechnologies.Razor.ClipboardIn your Blazor app's
Startup.cs, register the 'ClipboardService'.public void ConfigureServices(IServiceCollection services) { ... services.AddClipboard(); ... }Add this script tag in your root html file (Likely _Host.cshtml for Blazor Server Apps or index.html for Blazor WebAssembly Apps), right under the framework script tag. (i.e
<script src="_framework/blazor.server.js"></script>for Blazor Server Apps or<script src="_framework/blazor.webassembly.js"></script>for Blazor WebAssembly Apps)<script src="_content/CurrieTechnologies.Razor.Clipboard/clipboard.min.js"></script>Now you can inject the ClipboardService into any Blazor page and use it like this:
@using CurrieTechnologies.Razor.Clipboard @inject ClipboardService clipboard <input @bind="textValue" /> <button @onclick="(async e => await clipboard.WriteTextAsync(textValue))">Copy To Clipboard</button> <button @onclick="(async e => textValue = await clipboard.ReadTextAsync())">Paste From Clipboard</button> @code { string textValue = string.Empty; }
Compatibility
| Chrome | Edge Legacy | Edge (Chromium) | Firefox | IE | Opera | Safari |
|---|---|---|---|---|---|---|
| ✔️ 63+ | ❌ | ✔️ | ❌* | ❌ | ✔️ 53+ | ✔️ 13.1+ |
* Firefox does support the clipboard API, but in a very restricted way that Blazor doesn't support.
Clipboard API Gotchas
The Clipboard API is a relatively new API and presents some security concerns, so keep these in mind.
- Clipboard events can only be raised in response to user input.
- Focus must be on the DOM window. (not the debugger, or another window)
- The page must be served over HTTPS
References
No packages depend on CurrieTechnologies.Razor.Clipboard.
add .NET 7 support
.NET Core 3.1
- Microsoft.AspNetCore.Components (>= 3.1.0 && < 5.0.0)
- Microsoft.AspNetCore.Components.Web (>= 3.1.0 && < 5.0.0)
.NET 6.0
- Microsoft.AspNetCore.Components (>= 6.0.0 && < 7.0.0)
- Microsoft.AspNetCore.Components.Web (>= 6.0.0 && < 7.0.0)
.NET 7.0
- Microsoft.AspNetCore.Components (>= 7.0.0 && < 8.0.0)
- Microsoft.AspNetCore.Components.Web (>= 7.0.0 && < 8.0.0)
.NET Standard 2.0
- Microsoft.AspNetCore.Components (>= 3.1.0)
- Microsoft.AspNetCore.Components.Web (>= 3.1.0)
| Version | Downloads | Last updated |
|---|---|---|
| 1.6.0 | 2 | 12/23/2025 |
| 1.5.0 | 1 | 12/23/2025 |
| 1.4.0 | 1 | 12/23/2025 |
| 1.3.1 | 1 | 12/23/2025 |
| 1.3.0 | 1 | 12/23/2025 |
| 1.2.3 | 1 | 12/23/2025 |
| 1.2.2 | 1 | 12/23/2025 |
| 1.2.1 | 1 | 12/23/2025 |
| 1.2.0 | 1 | 12/23/2025 |
| 1.1.0 | 1 | 12/23/2025 |
| 1.0.0 | 1 | 12/23/2025 |
| 0.5.0 | 1 | 12/23/2025 |
| 0.4.0 | 1 | 12/23/2025 |
| 0.3.0 | 1 | 12/23/2025 |
| 0.2.0 | 1 | 12/23/2025 |
| 0.1.0 | 1 | 12/23/2025 |