New Component: st-copy, a new way to copy anything

Hi Streamlit Community! :waving_hand:

I’m excited to introduce st-copy, a new Streamlit component that adds a customizable “copy to clipboard” button to your apps.

:magnifying_glass_tilted_left: 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.

:sparkles: 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.

:rocket: Installation

pip install st-copy

:test_tube: Example Usage

from st_copy import copy_button

copy_button(
    "Text to copy",
    tooltip="Copy this text",
    copied_label="Copied!",
    icon="st",
)

:television: Live Demo

Check out the live demo app here: st-copy.streamlit.app

:package: 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!

4 Likes

This is great!