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, show_title=True, show_divider=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)
  • show_title (bool): Whether to show the title header (default: True)
  • show_divider (bool): Whether to show the divider line below the header (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.2.tar.gz (4.9 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.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for st_modal-1.0.2.tar.gz
Algorithm Hash digest
SHA256 71e9d2afa0b5ddbb7a073aca4709f9113dac5925c4e182129673c502fe648085
MD5 34f4e7c04c332b8a0ca0d4c3be9ee83c
BLAKE2b-256 ce1383e6b8caf0c04b569610dc992bcdc1cf2751be2afdd4dc1465babfe5db10

See more details on using hashes here.

File details

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

File metadata

  • Download URL: st_modal-1.0.2-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-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e86bf86ff9c0e5b7ea303b8d54957e253b26cc3ecb7ee029fc0e6e62d9c37043
MD5 c73811443316e49f6f0e63f40c1bbb93
BLAKE2b-256 7fccf9b840d0cb88d10a45cdc1813d5d8d7c7a209ce094c03e6293efd2a8a59b

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