Skip to main content

Attributes

id
str
The identifier used to retrieve the widget value from the settings.
label
str
The label of the input widget.
mode
Literal['single', 'range']
default:"'single'"
Selection mode. "single" selects one date, "range" selects a start and end date.
initial
str | date | tuple[str | date, str | date] | None
The initial value. For "single" mode, pass an ISO date string or date object. For "range" mode, pass a tuple of two values (start, end).
min_date
str | date | None
Minimum selectable date. Dates before this are disabled in the calendar.
max_date
str | date | None
Maximum selectable date. Dates after this are disabled in the calendar.
format
str | None
Display format string using date-fns format tokens (e.g. "yyyy/MM/dd").
placeholder
str | None
Placeholder text shown when no date is selected.
tooltip
str
The tooltip text shown when hovering over the tooltip icon next to the label.
description
str
The text displayed underneath the input widget.
Since version 2.9.6.

Usage

Single date
import chainlit as cl
from chainlit.input_widget import DatePicker


@cl.on_chat_start
async def start():
    settings = await cl.ChatSettings(
        [
            DatePicker(
                id="start_date",
                label="Start Date",
                placeholder="Pick a date",
                min_date="2025-01-01",
                max_date="2026-12-31",
            )
        ]
    ).send()
    value = settings["start_date"]
Date range
import chainlit as cl
from chainlit.input_widget import DatePicker


@cl.on_chat_start
async def start():
    settings = await cl.ChatSettings(
        [
            DatePicker(
                id="date_range",
                label="Date Range",
                mode="range",
                initial=("2025-06-01", "2025-06-30"),
            )
        ]
    ).send()
    value = settings["date_range"]