Skip to main content

Streamlit Copy-to-Clipboard Button Component

Streamlit App PyPI Python Version GitHub License Ask DeepWiki

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.

✨ Features

  • Streamlit theme aware: Adapts icon color & tooltip style automatically; works in both light and dark themes.
  • Inline layout: Built on Streamlit Custom Components v2 (frameless, no iframe), so the button aligns beside other elements inside st.container(horizontal=True).
  • Two icon styles: Google Material Symbols (default) or the native Streamlit code‑block icon.
  • Custom tooltip & "Copied!" label: Localized UI in one line.
  • Keyboard‑friendly: Fully focusable, press Enter/Space to copy.

🔧 Installation

pip install st-copy

⚡ Quick start

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

🛠 API

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.

Requirements

  • Python 3.10 or newer.
  • Streamlit 1.56 or newer (the component uses the Custom Components v2 API).
  • Clipboard API requires a secure (HTTPS) context when deployed.

🎨 Examples

See examples/app.py for a chat‑style demo that showcases every argument and the deployed version at https://st-copy.streamlit.app/.

Metadata

Release files for st-copy 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for st-copy 2.0.0
File Size Uploaded
st_copy-2.0.0.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for st-copy 2.0.0
File Interpreter ABI Platform
st_copy-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / st_copy-2.0.0.tar.gz

Download URL st_copy-2.0.0.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3810e5f380a8649d966ad9b7755fdb559ecf9a093e12449c979c15e30e1d7de2
BLAKE2b-256 checksum
How to use checksums
ba613249c3648034a9ba0382d823d7da5186b0a241420efe9e6edf674c15e4d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 17, 2026.

Transparency log

Release files / st_copy-2.0.0-py3-none-any.whl

Download URL st_copy-2.0.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd6ef78040c257a5070bf10837ffadb930b3039d1c838a57fc9238711986736a
BLAKE2b-256 checksum
How to use checksums
0c9c59939ae5517bf6e7f787c02e68866b7d5db0f063cc707fed0508cf2cba0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page