You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

st-copy

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

st-copy

Streamlit copy‑to‑clipboard button component

1.1.2
pipPyPI
Maintainers
1

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]:
ParameterType / DefaultDescription
textstrText placed on the user’s clipboard.
iconLiteral['material_symbols', 'st']
default 'material_symbols'
Icon style: Google Material content_copy (material_symbols) or Streamlit’s native code‑block icon (st).
tooltipstr, default 'Copy'Tooltip shown on hover/focus.
copied_labelstr, default 'Copied!'Small label displayed for ~1 s after a successful copy.
keystr | None, default NoneUnique component key; if omitted a random UUIDv4 is generated.
Returnsbool | NoneTrue – 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/.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts