Skip to main content

Streamlit copy‑to‑clipboard button component

Project description

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 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

⚡ 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

  • Streamlit 1.45 or newer.
  • 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/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

st_copy-1.1.2.tar.gz (59.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

st_copy-1.1.2-py3-none-any.whl (58.8 kB view details)

Uploaded Python 3

File details

Details for the file st_copy-1.1.2.tar.gz.

File metadata

  • Download URL: st_copy-1.1.2.tar.gz
  • Upload date:
  • Size: 59.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for st_copy-1.1.2.tar.gz
Algorithm Hash digest
SHA256 0cb7bb905c42ce4f230ae5731caf0ee9cd9d996028c5b7960d88b980e316e5c1
MD5 117d40265c1032510077e30519ca0397
BLAKE2b-256 dac35f04bd50336f8c7ea20fab64fe440493795924daa1ccb8fedaed068f8622

See more details on using hashes here.

Provenance

The following attestation bundles were made for st_copy-1.1.2.tar.gz:

Publisher: python-publish.yml on alex-feel/st-copy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file st_copy-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: st_copy-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 58.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for st_copy-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1d7b0acecad993391256e9f7bf9a8b8fd376883cfdb41b056721b893b963abd8
MD5 7dd4ed2593a4b37c567a236a9fb26faa
BLAKE2b-256 f38dfbc123c24dc5199133c27f59a517c309588d4046b250eeab6a2ec3c01584

See more details on using hashes here.

Provenance

The following attestation bundles were made for st_copy-1.1.2-py3-none-any.whl:

Publisher: python-publish.yml on alex-feel/st-copy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page