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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for st_modal-0.1.3.tar.gz
Algorithm Hash digest
SHA256 27375a476e66ccc26a668fa059d8f842fcec2c012bd132de81f9f44eaee5b8b5
MD5 e49025cd46c170643262a712997d52e4
BLAKE2b-256 b1aca3509a267711e896b8c96732f26c9ffc41ccd9d4208d3ed0fec80353241b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for st_modal-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3db6bd7e31b283e6858fbb740355f547f2243810d216c2f5e1ae597d6678d355
MD5 984dd449fc0abd4a88964ce6d3c001bf
BLAKE2b-256 1fbf399b59c192dad65a7f20e8f2ec71386b986662cca0c2cc58344c13624492

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