This package provides Blazor applications with access to the browser's Clipboard API
This package is depracted. Use CurrieTechnologies.Razor.Clipboard
-
In your Blazor app, add the
CurrieTechnologies.Blazor.Clipboard
NuGet packageInstall-Package CurrieTechnologies.Blazor.Clipboard
-
In your Blazor app's
Startup.cs
, register the 'ClipboardService'.public void ConfigureServices(IServiceCollection services) { ... services.AddClipboard(); ... }
-
Now you can inject the ClipboardService into any Blazor page and use it like this:
@using CurrieTechnologies.Blazor.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; }