5.0.3 • Published 6 months ago

react-codecopy v5.0.3

Weekly downloads
224
License
MIT
Repository
github
Last release
6 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.3

6 months ago

5.0.2

8 months ago

5.0.1

1 year ago

5.0.0

2 years ago

4.2.1

4 years ago

4.2.0

4 years ago

4.1.0

4 years ago

4.0.1

5 years ago

3.0.0

5 years ago

2.2.0

5 years ago

2.1.4

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago