https://github.com/pgarrett-scripps/streamlit_notify
Queues and displays Streamlit Status Elements after rerun
https://github.com/pgarrett-scripps/streamlit_notify
streamlit streamlit-component streamlit-components
Last synced: 3 months ago
JSON representation
Queues and displays Streamlit Status Elements after rerun
- Host: GitHub
- URL: https://github.com/pgarrett-scripps/streamlit_notify
- Owner: pgarrett-scripps
- Created: 2025-06-02T18:22:42.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-27T00:20:47.000Z (12 months ago)
- Last Synced: 2025-06-27T00:40:20.439Z (12 months ago)
- Topics: streamlit, streamlit-component, streamlit-components
- Language: Python
- Homepage: https://streamlit-notify.readthedocs.io/en/latest/usage.html
- Size: 4.39 MB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELONG.md
Awesome Lists containing this project
README
# Streamlit-Notify
A Streamlit component that provides status elements that persist across reruns.
Demo App: https://st-notify.streamlit.app/

## Installation
```bash
pip install streamlit-notify
```
## Development
```bash
pip install -r requirements-dev.txt
pre-commit install # now pre-commit will run automatically on git commit
```
It is also possible to run pre-commit via: `pre-commit run --all-files`
## Documentation
Full documentation is available at [Read the Docs](https://streamlit-notify.readthedocs.io/).
To build the documentation locally:
```bash
cd docs
pip install -r requirements.txt
make html
```
Then open `docs/build/html/index.html` in your browser.
## Supported Status Elements
- `stn.toast`: Toast notifications
- `stn.balloons`: Balloon animations
- `stn.snow`: Snow animations
- `stn.success`: Success messages
- `stn.info`: Info messages
- `stn.error`: Error messages
- `stn.warning`: Warning messages
- `stn.exception`: Exception messages
## How It Works
This package wraps standard Streamlit status element to enable queueing. Notifications are stored in Streamlit's session state and displayed during the next rerun cycle.
## Basic Usage
```python
import streamlit as st
import streamlit_notify as stn
# Display all queued notifications at the beginning of your app. This will also clear the list.
stn.notify()
# Add a notification that will be displayed on the next rerun
if st.button("Show Toast"):
stn.toast("This is a toast message", icon="✅")
st.rerun()
if st.button("Show Balloons"):
stn.balloons()
st.rerun()
if st.button("Show Success Message"):
stn.success("Operation successful!")
st.rerun()
```
#### Priority Support
```python
# Higher priority notifications are displayed first
stn.info("High priority message", priority=10)
stn.info("Low priority message", priority=-5)
```
#### Passing User Data
```python
# Higher priority notifications are displayed first
stn.info("High priority message", data="Hello World")
stn.info("Low priority message", data={'Hello': 'World'})
```
#### Getting all notifications
```python
# returns a dict mapping notification types to list of notifications
notifications = stn.get_notifications()
error_notifications = notifications['error']
toast_notifications = notifications['toast']
# or you can get the notifications directly from the stn widget
error_notifications = stn.error.get_notifications()
```
#### Clearing notifications
```python
# clears all notifications
stn.clear_notifications()
# clears notifications of only a specific type
stn.error.clear_notifications()
```
#### Checking if any notifications need to be shown
```python
# check if any notifications exist across all types
stn.has_notifications()
# check only specific type
stn.error.has_notifications()
```