Skip to main content

Modal for streamlit

Project description

st-modal

A modern modal dialog component for Streamlit applications. This is a fork of the original streamlit_modal with improvements and adjustments.

Installation

pip install st-modal

Quick Start

import streamlit as st
from st_modal import Modal

# Create modal
modal = Modal("My Modal", key="my-modal")

# Trigger to open modal
if st.button("Open Modal"):
    modal.open()

# Modal content
if modal.is_open():
    with modal.container():
        st.write("Hello from inside the modal!")
        
        value = st.slider("Pick a value", 0, 100, 50)
        st.write(f"Selected: {value}")
        
        if st.button("Close", key="close-modal"):
            modal.close()

API Reference

Modal Class

Modal(title, key, padding=20, max_width=744, show_close_button=True)

Parameters:

  • title (str): Title displayed at the top of the modal
  • key (str): Unique identifier for the modal (required)
  • padding (int): Internal padding in pixels (default: 20)
  • max_width (int): Maximum width in pixels (default: 744)
  • show_close_button (bool): Whether to show the X close button (default: True)

Methods:

  • modal.open(): Opens the modal and triggers a rerun
  • modal.close(): Closes the modal and triggers a rerun
  • modal.is_open(): Returns True if modal is currently open
  • modal.container(): Context manager for adding content to the modal

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_modal-1.0.0.tar.gz (5.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_modal-1.0.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file st_modal-1.0.0.tar.gz.

File metadata

  • Download URL: st_modal-1.0.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for st_modal-1.0.0.tar.gz
Algorithm Hash digest
SHA256 34057ef8a3108989792d185f3417c93171ebdd09f849bd9ba07c89b05df9bed5
MD5 03d8b7065cf19253146bdb4f3ff7909c
BLAKE2b-256 e7f1a8599a9e01a0fa02ab781ead72522c0806ffb8c85658ef83f210382381f9

See more details on using hashes here.

File details

Details for the file st_modal-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: st_modal-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for st_modal-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d585c16fe71c42349c8a81baf4638dda882ed33c3cf722a683eabe4b099e8ab7
MD5 81d2cdb3a5f6253af167f30c615bc230
BLAKE2b-256 93ca5c13a1d1b78fa4ce9a11ff0af901c3777d0eb752a2c836d24fc9dd0129be

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