Hi Streamlit Community!
I’m excited to introduce st-copy
, a new Streamlit component that adds a customizable “copy to clipboard” button to your apps.
What is st-copy
?
st-copy
allows you to add a copy button to any text content in your Streamlit app. It’s especially useful for copying code snippets, messages, or any other text, enhancing user interaction.
Features
- 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.
Installation
pip install st-copy
Example Usage
from st_copy import copy_button
copy_button(
"Text to copy",
tooltip="Copy this text",
copied_label="Copied!",
icon="st",
)
Live Demo
Check out the live demo app here: st-copy.streamlit.app
Source Code
Explore the source code on GitHub: alex-feel/st-copy
Feel free to try it out and let me know your thoughts or any suggestions for improvement!