Skip to main content

A lightweight clipboard copy utility for Streamlit, supporting both HTTP and HTTPS environments seamlessly.

Project description

Clipboard Copy Utilities for Streamlit

This Python package provides easy-to-use functions to copy text to the clipboard within Streamlit applications, supporting both HTTP and HTTPS contexts.

Key Features

  • Works seamlessly on both HTTP and HTTPS:
    Supports the modern, secure Clipboard API (navigator.clipboard.writeText) used in HTTPS environments,
    and falls back to the legacy document.execCommand('copy') method for HTTP or older browsers.

  • No dependency on UI elements:
    Clipboard copy commands can be triggered programmatically anywhere in your Streamlit app
    without requiring explicit user interaction with buttons, making integration flexible and convenient.

  • Fully compatible with Streamlit's iframe-based rendering:
    1% UI footprint — runs almost invisibly without affecting layout.

Why Use This Package?

Streamlit apps run inside iframes and are often served over HTTPS, which imposes strict browser security policies on clipboard access.
This package provides a reliable way to copy text to the clipboard regardless of the protocol or browser limitations by using both secure and fallback methods.

Installation

pip install st-clipboard

Usage Example

Here is an example Streamlit app showing two columns with text inputs and buttons — one using the secure clipboard copy (for HTTPS), and the other using the unsecured fallback (for HTTP):

import streamlit as st

from st_clipboard import copy_to_clipboard, copy_to_clipboard_unsecured


# Create two columns: HTTPS (left), HTTP (right)
col_https, col_http = st.columns(2)

with col_https:
    st.markdown("### HTTPS Clipboard Copy")
    https_text = st.text_input("Enter text to copy (HTTPS):", value="Hello HTTPS")
    if st.button("Copy to clipboard (HTTPS)"):
        copy_to_clipboard(https_text)
        st.success("Copied to clipboard using secure method!")

with col_http:
    st.markdown("### HTTP Clipboard Copy")
    http_text = st.text_input("Enter text to copy (HTTP):", value="Hello HTTP")
    if st.button("Copy to clipboard (HTTP)"):
        copy_to_clipboard_unsecured(http_text)
        st.success("Copied to clipboard using unsecured method!")

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_clipboard-0.0.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

st_clipboard-0.0.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file st_clipboard-0.0.1.tar.gz.

File metadata

  • Download URL: st_clipboard-0.0.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for st_clipboard-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5537bf869f37230a6142290497f3fc98de8181f3f1746e2aefaaf4d75ee103e0
MD5 3396887428e1358c23414c6cf00c66eb
BLAKE2b-256 20748a7cb27056cca5a5264f705eb077106e0ed3ed530f600da536619c9915f3

See more details on using hashes here.

File details

Details for the file st_clipboard-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: st_clipboard-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for st_clipboard-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c8efcec6628cd4f8dd13b4cf9d850d1032d81f5a46cfdcfa2463f14d8c8b9e90
MD5 d7069cbea26799a2fc6ee494c5a7822e
BLAKE2b-256 ba770a9008e9f3ded535dcd22326346033e09e9206e2dba3a3cd0fbc2c78a82b

See more details on using hashes here.

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