<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/add-copy-to-clipboard-button-on-any-html-element-gxh2cdjxg" -->

---
title: Add “Copy to clipboard” button on any HTML element
description: This 1-liner will copy any piece of text from a webpage to clipboard. It will work for all of type of frontend frameworks(including SSR and JAM-stack) Core...
canonical: https://daily.dev/posts/add-copy-to-clipboard-button-on-any-html-element-gxh2cdjxg
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Add “Copy to clipboard” button on any HTML element | daily.dev
og:description: This 1-liner will copy any piece of text from a webpage to clipboard. It will work for all of type of frontend frameworks(including SSR and JAM-stack) Core...
og:url: https://daily.dev/posts/add-copy-to-clipboard-button-on-any-html-element-gxh2cdjxg
og:image: https://api.daily.dev/og/posts/Gxh2cDJXg.png
og:image:alt: Add “Copy to clipboard” button on any HTML element
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Add “Copy to clipboard” button on any HTML element

**[Vue.js Developers](https://daily.dev/sources/vuejsdevelopers)** · 3 min read · 11 upvotes · 0 comments

## Summary

This 1-liner will copy any piece of text from a webpage to clipboard. It will work for all of type of frontend frameworks(including SSR and JAM-stack) Core idea will be same but implementation may differ across frameworks. More info along with its limitations & browser support can be found here.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/js-dojo/add-copy-to-clipboard-button-to-any-html-element-325326356468>

---

Tags: [#general-programming](https://daily.dev/tags/general-programming), [#html](https://daily.dev/tags/html), [#vuejs](https://daily.dev/tags/vuejs)

[View this post on daily.dev](https://daily.dev/posts/add-copy-to-clipboard-button-on-any-html-element-gxh2cdjxg)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Add “Copy to clipboard” button on any HTML element","url":"https://daily.dev/posts/add-copy-to-clipboard-button-on-any-html-element-gxh2cdjxg","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/add-copy-to-clipboard-button-on-any-html-element-gxh2cdjxg"},"datePublished":"2021-09-25T22:59:24.766Z","dateModified":"2021-10-07T14:17:10.317Z","description":"This 1-liner will copy any piece of text from a webpage to clipboard. It will work for all of type of frontend frameworks(including SSR and JAM-stack) Core...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bbb088a99a4e602f74eea877800c3012","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bbb088a99a4e602f74eea877800c3012","isAccessibleForFree":true,"articleSection":"Vue.js Developers","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Vue.js Developers","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/3db05bfc08fa42c6b37bae670192c2be","url":"https://daily.dev/sources/vuejsdevelopers"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/add-copy-to-clipboard-button-on-any-html-element-gxh2cdjxg","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":11},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"general-programming,html,vuejs","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Vue.js Developers","item":"https://daily.dev/sources/vuejsdevelopers"},{"@type":"ListItem","position":3,"name":"Add “Copy to clipboard” button on any HTML element"}]}
```

