.md →
CopyToClipboard API#
CopyToClipboard is a single button that writes text_to_copy to the OS clipboard when
clicked. Because text_to_copy is a synced traitlet, you can keep setting it from Python
and the button always carries the current value — useful for a generated prompt, a
connection string, or a block of SQL that the reader needs to paste somewhere else.
See also: ColorPicker for producing a hex string worth copying, AnnotationWidget for capturing text the other direction, and HTMLRefreshWidget for showing that text in the cell instead.
Bases: AnyWidget
Button widget that copies the provided text_to_copy payload.
Examples:
import marimo as mo
from wigglystuff import CopyToClipboard
button = mo.ui.anywidget(CopyToClipboard(text_to_copy="Hello, world!"))
button
Create a CopyToClipboard button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text_to_copy
|
str
|
Initial string placed on the clipboard when clicked. |
''
|
**kwargs
|
Any
|
Forwarded to |
{}
|
Source code in wigglystuff/copy_to_clipboard.py
Synced traitlets#
| Traitlet | Type | Notes |
|---|---|---|
text_to_copy |
str |
Payload copied when the button is pressed. |