{"id":47728221,"url":"https://github.com/soenneker/soenneker.blazor.utils.clipboard","last_synced_at":"2026-05-03T00:07:15.267Z","repository":{"id":348289636,"uuid":"1197289993","full_name":"soenneker/soenneker.blazor.utils.clipboard","owner":"soenneker","description":"A Blazor interop library for clipboard management","archived":false,"fork":false,"pushed_at":"2026-04-29T05:16:00.000Z","size":240,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-29T07:14:33.666Z","etag":null,"topics":["blazor","blazorclipboardutil","blazorlibrary","clipboard","csharp","dotnet","razor","utility","utils"],"latest_commit_sha":null,"homepage":"https://soenneker.com","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soenneker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"soenneker","thanks_dev":"soenneker"}},"created_at":"2026-03-31T13:19:57.000Z","updated_at":"2026-04-29T05:16:02.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/soenneker/soenneker.blazor.utils.clipboard","commit_stats":null,"previous_names":["soenneker/soenneker.blazor.utils.clipboard"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/soenneker/soenneker.blazor.utils.clipboard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soenneker%2Fsoenneker.blazor.utils.clipboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soenneker%2Fsoenneker.blazor.utils.clipboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soenneker%2Fsoenneker.blazor.utils.clipboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soenneker%2Fsoenneker.blazor.utils.clipboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soenneker","download_url":"https://codeload.github.com/soenneker/soenneker.blazor.utils.clipboard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soenneker%2Fsoenneker.blazor.utils.clipboard/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32552369,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T22:28:24.418Z","status":"ssl_error","status_checked_at":"2026-05-02T22:28:14.225Z","response_time":132,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blazor","blazorclipboardutil","blazorlibrary","clipboard","csharp","dotnet","razor","utility","utils"],"created_at":"2026-04-02T21:01:35.925Z","updated_at":"2026-05-03T00:07:15.251Z","avatar_url":"https://github.com/soenneker.png","language":"CSS","funding_links":["https://github.com/sponsors/soenneker","https://thanks.dev/soenneker"],"categories":[],"sub_categories":[],"readme":"[![](https://img.shields.io/nuget/v/soenneker.blazor.utils.clipboard.svg?style=for-the-badge)](https://www.nuget.org/packages/soenneker.blazor.utils.clipboard/)\n[![](https://img.shields.io/github/actions/workflow/status/soenneker/soenneker.blazor.utils.clipboard/publish-package.yml?style=for-the-badge)](https://github.com/soenneker/soenneker.blazor.utils.clipboard/actions/workflows/publish-package.yml)\n[![](https://img.shields.io/nuget/dt/soenneker.blazor.utils.clipboard.svg?style=for-the-badge)](https://www.nuget.org/packages/soenneker.blazor.utils.clipboard/)\n[![](https://img.shields.io/badge/Demo-Live-blueviolet?style=for-the-badge\u0026logo=github)](https://soenneker.github.io/soenneker.blazor.utils.clipboard)\n\n# Soenneker.Blazor.Utils.Clipboard\n\nBlazor 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.\n\n---\n\n## Install\n\n```bash\ndotnet add package Soenneker.Blazor.Utils.Clipboard\n```\n\n---\n\n## Setup\n\nRegister clipboard services (e.g. in `Program.cs`):\n\n```csharp\nbuilder.Services.AddClipboardAsScoped();\n```\n\nInject `IClipboardUtil` where you need it:\n\n```csharp\n@inject IClipboardUtil Clipboard\n```\n\n---\n\n## Usage\n\n### Check if clipboard is available\n\nUse this when you might not be in a secure context (e.g. prerender, some hosts). Result is cached.\n\n```csharp\nif (await Clipboard.HasClipboard())\n{\n    await Clipboard.CopyText(\"Hello\");\n}\n```\n\n### Read and write plain text\n\n```csharp\n// Write\nawait Clipboard.WriteText(\"Hello, world\");\nawait Clipboard.CopyText(\"Same as WriteText\");  // alias\n\n// Read (may throw if permission denied)\nstring text = await Clipboard.ReadText();\n```\n\n### Try read / try write (no throw)\n\nUse these to avoid try/catch when you only care about success or failure:\n\n```csharp\n// Try read: (success, text)\nvar (ok, text) = await Clipboard.TryReadText();\nif (ok \u0026\u0026 !string.IsNullOrEmpty(text))\n    Console.WriteLine(text);\n\n// Try write: true if copied, false on error\nbool copied = await Clipboard.TryWriteText(\"Hello\");\nif (!copied)\n    ShowMessage(\"Could not copy to clipboard\");\n```\n\n### Permission state\n\nCheck read/write permission state (where supported; returns `Unsupported` in e.g. Firefox/Safari):\n\n```csharp\nvar readState = await Clipboard.GetReadPermissionState();   // Granted, Denied, Prompt, Unsupported\nvar writeState = await Clipboard.GetWritePermissionState();\n```\n\n### Clear clipboard\n\n```csharp\nawait Clipboard.Clear();\n```\n\n### Rich content: plain + HTML\n\nUseful when pasting into rich editors (plain fallback + HTML):\n\n```csharp\nawait Clipboard.CopyPlainAndHtml(\"Fallback text\", \"\u003cp\u003eRich \u003cb\u003eHTML\u003c/b\u003e\u003c/p\u003e\");\n```\n\n### Read/write multiple types (text, HTML, images)\n\nFor full control, use `Read()` and `Write()` with `ClipboardItemDto`. Each item has a dictionary of MIME type → content (text or data URL for images).\n\n```csharp\n// Read all items and types from clipboard\nIReadOnlyList\u003cClipboardItemDto\u003e items = await Clipboard.Read();\nforeach (var item in items)\n{\n    foreach (var (mimeType, content) in item.Types)\n    {\n        if (content.StartsWith(\"data:image/\"))\n            // image as data URL\n        else\n            // text (e.g. text/plain, text/html)\n    }\n}\n\n// Write custom items\nawait Clipboard.Write(new[]\n{\n    ClipboardItems.CreatePlainAndHtml(\"Plain\", \"\u003cp\u003eHTML\u003c/p\u003e\"),\n    ClipboardItems.CreateImage(\"data:image/png;base64,...\")\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoenneker%2Fsoenneker.blazor.utils.clipboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoenneker%2Fsoenneker.blazor.utils.clipboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoenneker%2Fsoenneker.blazor.utils.clipboard/lists"}