Skip to main content

An advanced Streamlit date input component with event markers and multiple display modes

Project description

Streamlit Date Events

An enhanced date input component for Streamlit with event markers and multiple display modes.

Features

  • 📅 Calendar-based date picker with Streamlit styling
  • 🔴 Event markers (small dots) under specific dates
  • 🎨 Multiple event types with custom colors and labels
  • 📊 Legend showing event types
  • 💡 Tooltips on hover showing event details
  • 🎯 Two display modes: inline (always visible) or dropdown (click to open)
  • ⚙️ Min/max date restrictions
  • 🎨 Customizable event colors
  • 🔄 Backward compatible with simple event lists

Try it here

Installation

pip install streamlit-date-events

Quick Start

Simple Mode (Single Event Type)

import streamlit as st
from streamlit_date_events import date_input_with_events
from datetime import date, timedelta

# Define some event dates
today = date.today()
events = [
    today,
    today + timedelta(days=3),
    today + timedelta(days=7),
    today + timedelta(days=14),
]

# Use the component
selected_date = date_input_with_events(
    label="Select a date",
    value=today,
    event_dates=events,
    event_color="#FF4B4B",  # Streamlit red
)

if selected_date:
    st.write(f"You selected: {selected_date}")
    if selected_date in events:
        st.success("This date has an event! 🎉")

Advanced Mode (Multiple Event Types)

import streamlit as st
from streamlit_date_events import date_input_with_events
from datetime import date, timedelta

today = date.today()

# Define multiple event types
event_types = {
    'meetings': {
        'dates': [today + timedelta(days=2), today + timedelta(days=7)],
        'color': '#FF4B4B',
        'label': 'Team Meetings'
    },
    'deadlines': {
        'dates': [today + timedelta(days=5), today + timedelta(days=12)],
        'color': '#FFA500',
        'label': 'Project Deadlines'
    },
    'holidays': {
        'dates': [today + timedelta(days=10)],
        'color': '#00C896',
        'label': 'Public Holidays'
    }
}

selected_date = date_input_with_events(
    label="Select a date",
    value=today,
    event_types=event_types,
    show_legend=True,
    mode="dropdown",  # or "inline"
)

if selected_date:
    st.write(f"Selected: {selected_date}")

Display Modes

Inline Mode (Default)

Calendar is always visible - best for single-purpose pages.

selected = date_input_with_events(
    label="Pick a date",
    mode="inline"
)

Dropdown Mode

Calendar opens on click - saves space on the page.

selected = date_input_with_events(
    label="Pick a date",
    mode="dropdown"
)

Parameters

date_input_with_events()

  • label (str): Label text for the component
  • value (date/datetime): Default selected date
  • event_dates (list): Simple list of dates with events (backward compatible)
  • event_types (dict): Advanced event configuration with multiple types:
    {
        'event_key': {
            'dates': [list of dates],
            'color': '#HEX_COLOR',
            'label': 'Display Name'
        }
    }
    
  • min_date (date/datetime): Minimum selectable date
  • max_date (date/datetime): Maximum selectable date
  • event_color (str): Default color for simple event_dates mode
  • show_legend (bool): Whether to show the legend (default: True)
  • mode (str): Display mode - "inline" or "dropdown" (default: "inline")
  • key (str): Unique key for the component

Examples

Booking System

import streamlit as st
from streamlit_date_events import date_input_with_events
from datetime import date

# Booked dates
booked_dates = [
    date(2024, 1, 15),
    date(2024, 1, 20),
    date(2024, 1, 25),
]

booking_date = date_input_with_events(
    label="Select booking date",
    value=date.today(),
    event_dates=booked_dates,
    event_color="#FF0000",
    mode="dropdown",
)

if booking_date:
    if booking_date in booked_dates:
        st.error("❌ This date is already booked")
    else:
        st.success(f"✅ {booking_date} is available!")

Project Timeline

project_timeline = {
    'milestones': {
        'dates': [date(2024, 1, 7), date(2024, 1, 14), date(2024, 1, 21)],
        'color': '#F59E0B',
        'label': 'Milestones'
    },
    'demos': {
        'dates': [date(2024, 1, 6), date(2024, 1, 13), date(2024, 1, 20)],
        'color': '#3B82F6',
        'label': 'Client Demos'
    },
    'deliveries': {
        'dates': [date(2024, 1, 28)],
        'color': '#EF4444',
        'label': 'Final Delivery'
    }
}

selected = date_input_with_events(
    label="Project Timeline",
    event_types=project_timeline,
    show_legend=True,
)

Overlapping Events

Dates can have multiple events - they'll show as multiple colored dots with a tooltip on hover.

overlapping = {
    'type1': {
        'dates': [date(2024, 1, 15)],  # Same date
        'color': '#FF4B4B',
        'label': 'Event Type 1'
    },
    'type2': {
        'dates': [date(2024, 1, 15)],  # Same date
        'color': '#00C896',
        'label': 'Event Type 2'
    }
}

selected = date_input_with_events(
    label="Hover to see multiple events",
    event_types=overlapping,
)

Development

Setup

# Clone the repository
git clone https://github.com/yourusername/streamlit-date-events.git
cd streamlit-date-events

# Install frontend dependencies
cd streamlit_date_events/frontend
npm install

# Install package in development mode
cd ../..
pip install -e .

Run Development Server

# Terminal 1: Run frontend
cd streamlit_date_events/frontend
npm start  # Runs on http://localhost:3000

# Terminal 2: Run Streamlit app
# Set _RELEASE = False in date_events.py first
streamlit run example_app.py

Build for Production

# Build frontend
cd streamlit_date_events/frontend
npm run build

# Set _RELEASE = True in date_events.py

# Build package
cd ../..
python -m build

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

If you encounter any issues or have questions, please open an issue on GitHub.

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

streamlit_date_events-0.1.4.tar.gz (571.8 kB view details)

Uploaded Source

Built Distribution

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

streamlit_date_events-0.1.4-py3-none-any.whl (571.7 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_date_events-0.1.4.tar.gz.

File metadata

  • Download URL: streamlit_date_events-0.1.4.tar.gz
  • Upload date:
  • Size: 571.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for streamlit_date_events-0.1.4.tar.gz
Algorithm Hash digest
SHA256 07617228b7d04fe7577efce1d2fddc4ff24001347160b956cec1db3bce528141
MD5 be7635aca7b51aaa0bff7a33f0868834
BLAKE2b-256 d0bcb595a20fead03141956f1ff5b9c0abba243f09023b854f81f94f25bf6cc1

See more details on using hashes here.

File details

Details for the file streamlit_date_events-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_date_events-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b4ff8277c1a2bbbce20cdbde5961d9f6ce319b12650cbc9e8e5920eb0dbed098
MD5 1bc579cf6dd97bfcb66df88dc1d6a085
BLAKE2b-256 658d50ba6a25a4ccb445577ea64f8eb50ba6248b51918c1c1679f3dc092a8f85

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