Clipboard

The CopyToClipboard component allows users to copy text to the Browser clipboard.

The component attaches a copy-to-clipboard action to the button of given 'button_id'. When clicked the given text to the browser's clipboard.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
import lorem
from reactpy import component, html

from reactpy_utils import CopyToClipboard

BUTTON_ID = "test-copy-btn"
TEXT = lorem.paragraph()


@component
def App():
    return html._(html.button({"id": BUTTON_ID}, "Copy to Clipboard"), CopyToClipboard(button_id=BUTTON_ID, text=TEXT))

Last update: November 21, 2024
Authors: Steve Jones