My Projects
st-copy — Streamlit Copy-to-Clipboard Button Component
A tiny, theme-aware Streamlit component that adds a one-click copy-to-clipboard button to any Streamlit app. Distributed as the st-copy PyPI package; used in AI chat UIs and prompt-output surfaces where a clean, accessible copy button was missing from the Streamlit toolbox.
Details & related links
Overview
st-copy is a tiny, theme-aware Streamlit component that adds a one-click copy-to-clipboard button to any Streamlit app — published on PyPI as st-copy under the MIT license, with the full source on GitHub.
You can try it live at st-copy.streamlit.app — a small demo that shows the button rendered inside chat messages, with all parameters in use.
The Problem
Streamlit's built-in widgets cover most app-building needs, but one small thing was consistently missing: a clean, theme-aware, keyboard-accessible copy-to-clipboard button that can sit inline next to assistant messages, generated prompts, install commands, or any other snippet users might want to copy. The options available outside Streamlit's core either looked out of place in a Streamlit theme, required heavier JavaScript dependencies than the task deserves, or didn't integrate cleanly with Streamlit's component API. In an AI chat UI — where copy buttons should feel native — that small gap was visible every time.
The Solution
st-copy is deliberately narrow: one function, a handful of arguments, one job.
- One-line usage.
copy_button('some text')drops a working copy button into the Streamlit layout. - Inline, frameless layout. Built on Streamlit's Custom Components v2 — the button renders directly in the app DOM with no iframe, so it sits flush beside other elements, including inside
st.container(horizontal=True). - Theme-aware out of the box. The button picks up Streamlit's light or dark theme automatically — icon color, tooltip style, and focus ring all follow the host app's palette.
- Two icon styles. A Google Material Symbols icon by default, or Streamlit's native code-block icon via
icon='st'for apps that want the button to blend into ast.code()visual lineage. - Localizable microcopy. The hover tooltip (
tooltip='Copy') and post-copy confirmation label (copied_label='Copied!') are plain-string arguments, so the component drops cleanly into apps serving non-English users. - Keyboard-accessible. The button is fully focusable; pressing Enter or Space copies, matching how users expect a well-behaved web button to work.
- Truthful return value. The function returns
Trueon a successful copy,Falseif the browser Clipboard API refuses, orNonewhile the button hasn't been clicked yet — useful for apps that want to confirm or log the copy event.
Consumers only need pip install st-copy and import st_copy — the prebuilt frontend bundle is embedded in the wheel, so there is no Node.js requirement on the consumer side.
alex-feel / st-copy
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.
Usage and Adoption
- Published on PyPI as
st-copy. - Public GitHub repository at alex-feel/st-copy under the MIT license, with CI/CD and release automation.
- Live demo at st-copy.streamlit.app — deployed on Streamlit Community Cloud, source in the companion st-copy-example repository.
- Requirements stay lean: Streamlit 1.56 or newer (for the Custom Components v2 API), Python 3.10 or newer, and an HTTPS context at runtime (standard for deployed Streamlit apps).
Why I Built It
st-copy came directly out of my applied AI work — in particular, shipping Streamlit-based UIs for AI products like AILA (AI Localisation Assistant) at Spotware and other internal Streamlit tools for AI workflows. Those apps kept running into the same tiny paper-cut: the chat message was there, the generated text was there, but the "copy this" affordance users expect from modern chat UIs simply wasn't in Streamlit's toolbox at a quality the apps deserved. I wanted something beautiful, functional, and simple — so rather than work around the gap in every app, I built the missing primitive once, published it, and put it on my own apps.
That kept the Streamlit apps clean and made the component available to the wider Streamlit community — the kind of small, sharp open-source tool the ecosystem benefits from.
My Role
I designed, built, and maintain st-copy end-to-end as a solo open-source project — the Python wrapper and the frontend, the theme-aware behavior, the test suite, the release automation, and the PyPI distribution. It lives on my personal GitHub under an MIT license, and I accept issues and contributions from the Streamlit community.