# react-clipboard-animation

> A simple clipboard animation in react which allows the user to easily copy text.

Latest version **1.0.8** (published 2021-11-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-clipboard-animation
pnpm add react-clipboard-animation
yarn add react-clipboard-animation
bun add react-clipboard-animation
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2021-11-12 |
| First published | 2021-11-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 679.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Pranav Doshi |
| Maintainers | pranavdoshi |
| Keywords | react, react-clipboard, react-clipboard-text, react-clipboard-animation, react-copy-to-clipboard, react-copy-paste, clipboard, clipboard-animation |

## Links

- npm: https://www.npmjs.com/package/react-clipboard-animation
- Repository: https://github.com/ZaphodElevated/react-clipboard-animation
- Homepage: https://github.com/ZaphodElevated/react-clipboard-animation#readme
- Issues: https://github.com/ZaphodElevated/react-clipboard-animation/issues
- npm.io page: https://npm.io/package/react-clipboard-animation

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.8 (latest) — 2021-11-12
- 1.0.7 — 2021-11-08
- 1.0.6 — 2021-11-08
- 1.0.5 — 2021-11-08
- 1.0.4 — 2021-11-08
- 1.0.3 — 2021-11-08
- 1.0.2 — 2021-11-08
- 1.0.1 — 2021-11-07
- 1.0.0 — 2021-11-07

## README

# React Clipboard Animation [![npm](https://img.shields.io/npm/v/react-clipboard-animation.svg?style=flat-square)](https://www.npmjs.com/package/react-clipboard-animation)

A simple clipboard animation in react which allows the user to easily copy text.

![Clipboard Animation Demo](https://github.com/ZaphodElevated/react-clipboard-animation/blob/main/assets/demo.gif?raw=true)

# Installation

Install the package with npm or yarn with either of the following commands.

```
npm i react-clipboard-animation
```

```
yarn add react-clipboard-animation
```

Make sure to import the Clipboard component from the library after it is installed

```js
import Clipboard from 'react-clipboard-animation'
```

# Usage

```js
import './App.css'
import Clipboard from 'react-clipboard-animation'
import React, { useState, useEffect } from 'react'

function App() {
  const [copied, setCopied] = useState(false)

  useEffect(() => {
    const timeout = setTimeout(() => {
      if (copied) setCopied(false)
    }, 1000)

    return () => clearTimeout(timeout)
  }, [copied])

  return (
    <div className='App'>
      <div className='clipboard'>
        <h3 className='clipboard-text'>Hello World!</h3>
        <Clipboard
          copied={copied}
          setCopied={setCopied}
          text='Hello World!'
          color='white'
        />
      </div>
    </div>
  )
}
```

### Example Styling

```css
.App {
  text-align: center;
  background-color: #282c34;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: start;
  justify-content: start;
  font-size: calc(10px + 2vmin);
  color: white;
  gap: 1.5rem;
  padding: 2rem;
}

.clipboard {
  display: flex;
  justify-content: center;
  align-items: center;
}

.clipboard-text {
  font-size: 20px;
  font-weight: 300;
  margin-right: 10px;
}
```

# Options

`text` Text to be copied.

`color` Color of the icons. Default is black.

`copied` Boolean variable which returns true when the text is copied.

`setCopied` Function to set the copied variable. Required for checkmark animation to work.

# Browser Compatability

![Clipboard Animation Demo](https://github.com/ZaphodElevated/react-clipboard-animation/blob/main/assets/browser-compatability.png?raw=true)

_Source: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText_

# License

MIT

---
_Source: https://npm.io/package/react-clipboard-animation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
