Clipboard
Bootstrap 5 Clipboard
Copy to clipboard feature for the latest Bootstrap 5. Let your users easily copy text or links with one click.Note: Read the API tab to find all available options and advanced customization
Basic example
Create copy to clipboard by adding button with reference that is passed to useClipboard
hook
along with the value to be copied.
Copy from element
There is no difference if element is an input
or just div
element.
Here is text to copy!
Copy hardcoded value
By passing a string as first argument to useClipboard
you can hardcode value to copy.
Copy hardcoded value instead of text content.
Feedback example
An example of triggering feedback using an alert and reference.
Clipboard - API
Import
Properties
useClipboard
Name | Type | Default | Description | Example |
---|---|---|---|---|
text
|
string | '' |
A text to copy. |
useClipboard('Text', someRef)
|
trigger
|
React.Ref |
|
A trigger for copy. |
useClipboard('Text', someRef)
|