5.0.14 • Published 11 months ago

react-codecopy v5.0.14

Weekly downloads
224
License
MIT
Repository
github
Last release
11 months ago

react-codecopy

Last version NPM Status

"Copy to clipboard" button for your code snippets. Inspired in codecopy.

Install

$ npm install react-codecopy --save

Usage

import CodeCopy from 'react-codecopy'

const PreCode = props => (
  <Pre>
    <code {...props} />
  </Pre>
)

const Code = ({ theme, ...props } = {}) => (
  <CodeCopy theme={theme} text={props.children}>
    <PreCode {...props} />
  </CodeCopy>
)

return (
  <Code {...props}>{`<!-- Microlink SDK Vanilla/UMD bundle -->
  <script src="//cdn.jsdelivr.net/npm/microlinkjs@latest/umd/microlink.min.js"></script>`}
  </Code>
)

API

CodeCopy(options)

options

iconComponent

Type: component Default: ClipboardIcon

The clipboard icont to use.

text

Type: string

The text to be copied.

onCopy

Type: function

A function to be called after text is being copied to the clipboard.

copy

Type: function Default: text => navigator.clipboard.writeText(text)

The clipboard method to delegate into the copy action.

In case you need to support old browser, consider to call copee.

theme

Type: string Default: light

It determines the theme to be used, being possible 'light' and 'dark'.

Related

  • codecopy – "Copy to clipboard" button for your code snippets.

License

react-codecopy © Kiko Beats, released under the MIT License. Authored and maintained by Kiko Beats with help from contributors.

kikobeats.com · GitHub Kiko Beats · Twitter @Kikobeats

5.0.14

11 months ago

5.0.13

1 year ago

5.0.10

1 year ago

5.0.11

1 year ago

5.0.12

1 year ago

5.0.9

1 year ago

5.0.8

1 year ago

5.0.6

1 year ago

5.0.5

1 year ago

5.0.4

1 year ago

5.0.7

1 year ago

5.0.3

2 years ago

5.0.2

2 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.2.1

5 years ago

4.2.0

5 years ago

4.1.0

5 years ago

4.0.1

6 years ago

3.0.0

6 years ago

2.2.0

6 years ago

2.1.4

7 years ago

2.1.3

7 years ago

2.1.2

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago