Copy Button

Default


Copy From


Provide an element's ID as the from parameter, and its text will be copied. If the element is an input, its value will be copied; otherwise, the innerText will be used. Additionally, if a value prop is provided, it will override the content from the from element and be copied instead.

Copy Hook


We provide a usePBCopy hook that you can import to your project. This hook will return a function that you can call to copy the text to the clipboard.

usePBCopy({ from: 'your_id' }) will grab the innerText from your_id element, or value if it is an input element.


Available Props