A tiny, theme‑aware Streamlit component that adds a one‑click "copy-to-clipboard" button to your app — perfect for the chat UI, URLs or any other text the user might need to copy.
- Streamlit theme aware: Adapts icon colour & tooltip style automatically; works in both light and dark themes.
- Two icon styles: Google Material Symbols (default) or the native Streamlit code‑block icon.
- Custom tooltip & "Copied!" label: Localised UI in one line.
- Keyboard‑friendly: Fully focusable, press Enter/Space to copy.
pip install st-copy
import streamlit as st
from st_copy import copy_button
st.title('Minimal demo')
copy_button('Hello, Streamlit!') # one line – that's it 🎉
Run your script:
streamlit run app.py
def copy_button(
text: str,
*,
icon: Literal['material_symbols', 'st'] = 'material_symbols',
tooltip: str = 'Copy',
copied_label: str = 'Copied!',
key: Optional[str] = None,
) -> Optional[bool]:
Parameter | Type / Default | Description |
---|---|---|
text |
str | Text placed on the user’s clipboard. |
icon |
Literal['material_symbols', 'st'] default 'material_symbols' |
Icon style: Google Material content_copy (material_symbols ) or Streamlit’s native code‑block icon (st ). |
tooltip |
str, default 'Copy' |
Tooltip shown on hover/focus. |
copied_label |
str, default 'Copied!' |
Small label displayed for ~1 s after a successful copy. |
key |
str | None, default None |
Unique component key; if omitted a random UUIDv4 is generated. |
Returns | bool | None | True – copy succeeded; False – Clipboard API failed; None – button not clicked yet. |
- Streamlit 1.45 or newer.
- Clipboard API requires a secure (HTTPS) context when deployed.
See examples/app.py for a chat‑style demo that showcases every argument and the deployed version at https://st-copy.streamlit.app/.