{"id":18052713,"url":"https://github.com/cham11ng/react-copy-button","last_synced_at":"2025-04-10T19:42:00.139Z","repository":{"id":41377422,"uuid":"147848086","full_name":"cham11ng/react-copy-button","owner":"cham11ng","description":"Copy to clipboard react button (📋) component.","archived":false,"fork":false,"pushed_at":"2023-10-01T17:07:16.000Z","size":1635,"stargazers_count":8,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-14T13:04:51.449Z","etag":null,"topics":["babel","bun","clipboard","example-code","hacktoberfest","react","react-copy-button","rollup"],"latest_commit_sha":null,"homepage":"https://cham11ng.github.io/react-copy-button/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cham11ng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-07T16:22:48.000Z","updated_at":"2024-04-10T22:28:17.000Z","dependencies_parsed_at":"2023-10-01T17:53:17.764Z","dependency_job_id":null,"html_url":"https://github.com/cham11ng/react-copy-button","commit_stats":{"total_commits":80,"total_committers":4,"mean_commits":20.0,"dds":0.55,"last_synced_commit":"3c29cec1c058de5965b5f23da3937d941bc3f11a"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cham11ng%2Freact-copy-button","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cham11ng%2Freact-copy-button/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cham11ng%2Freact-copy-button/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cham11ng%2Freact-copy-button/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cham11ng","download_url":"https://codeload.github.com/cham11ng/react-copy-button/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281415,"owners_count":21077423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["babel","bun","clipboard","example-code","hacktoberfest","react","react-copy-button","rollup"],"created_at":"2024-10-30T23:12:56.405Z","updated_at":"2025-04-10T19:42:00.119Z","avatar_url":"https://github.com/cham11ng.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-copy-button\n\n\u003e Copy to clipboard react button component. Demo: https://cham11ng.github.io/react-copy-button/\n\n[![NPM](https://img.shields.io/npm/v/react-copy-button.svg)](https://www.npmjs.com/package/react-copy-button)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Deployment Status](https://github.com/cham11ng/react-copy-button/actions/workflows/deploy.yml/badge.svg)](https://github.com/cham11ng/react-copy-button/actions/workflows/deploy.yml)\n\n## Install\n\n```bash\nyarn add react-copy-button\nor\nbun install react-copy-button\n```\n\n## Usage\n\n```jsx\n// Functional Component with useRef hook.\nimport React from 'react';\nimport { useRef } from 'react';\nimport { useState } from 'react';\n\nfunction App() {\n  const imageRef = useRef();\n  const url =\n    'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/React-icon.svg/2000px-React-icon.svg.png';\n\n  return (\n    \u003cReact.Fragment\u003e\n      \u003cdiv ref={imageRef}\u003e\n        \u003cimg src={url} /\u003e\n      \u003c/div\u003e\n      \u003cCopyButton imageRef={imageRef}\u003eCopy Image\u003c/CopyButton\u003e\n\n      \u003cCopyButton text=\"Text to copy\"\u003eCopy Text\u003c/CopyButton\u003e\n      \u003cCopyButton imageURL={url}\u003eCopy Image (New)\u003c/CopyButton\u003e\n    \u003c/React.Fragment\u003e\n  );\n}\n\n// Class Component\nimport * as React from 'react';\n\nimport CopyButton from 'react-copy-button';\n\nconst url =\n  'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/React-icon.svg/2000px-React-icon.svg.png';\n\nclass Example extends React.Component {\n  constructor(props) {\n    super(props);\n\n    this.imageRef = React.createRef();\n  }\n\n  render() {\n    return (\n      \u003cReact.Fragment\u003e\n        \u003cdiv ref={this.imageRef}\u003e\n          \u003cimg src={url} /\u003e\n        \u003c/div\u003e\n        \u003cCopyButton imageRef={this.imageRef}\u003eCopy Image\u003c/CopyButton\u003e\n\n        \u003cCopyButton text=\"Text to copy\"\u003eCopy Text\u003c/CopyButton\u003e\n        \u003cCopyButton imageURL={url}\u003eCopy Image (New)\u003c/CopyButton\u003e\n      \u003c/React.Fragment\u003e\n    );\n  }\n}\n```\n\n## Development\n\n```bash\n# Package\n$ bun install\n\n$ bun link\n\n$ bun start\n\n$ bun run build\n\n# Example\n\n$ cd example\n\n$ bun install\n\n$ bun start\n\n$ bun run build\n```\n\n## Release and Publish\n\n```\n$ gh release create 0.2.1 --generate-notes --prerelease\n\n$ bun publish\n```\n\n## Browser compatibility\n\n- execCommand [here](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand#Browser_compatibility).\n- Navigator.clipboard [here](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API#browser_compatibility).\n\n## License\n\nMIT © [cham11ng](https://github.com/cham11ng)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcham11ng%2Freact-copy-button","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcham11ng%2Freact-copy-button","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcham11ng%2Freact-copy-button/lists"}