Skip to content

Calendar

Use a calendar to pick a date within a range. The calendar is an expanded form of a date picker.

Basic

Set mode='day' to show a calendar.

date = view(box('Pick a date', mode='day'))
view(f'You picked {date}.')

Screenshot

Set initial date

Set value= to pre-select a date.

Dates must be in ISO 8601 format. Date-only strings (e.g. "1970-01-01") are treated as UTC, not local.

date = view(box('Pick a date', mode='day', value='2021-10-10'))
view(f'You picked {date}.')

Screenshot

Set min date

Set min= to specify a minimum date.

date = view(box('Pick a date', mode='day', value='2021-10-10', min='2019-01-01'))
view(f'You picked {date}.')

Screenshot

Set max date

Set max= to specify a maximum date.

date = view(box('Pick a date', mode='day', value='2021-10-10', max='2022-12-31'))
view(f'You picked {date}.')

Screenshot

Combine min and max dates

Set both min= and max= to restrict selection between two dates.

date = view(box('Pick a date', mode='day', value='2021-10-10', min='2019-01-01', max='2022-12-31'))
view(f'You picked {date}.')

Screenshot

Set range

Set range= to a (min, max) tuple to restrict selection between two dates.

This is a shorthand notation for setting min= and max= individually.

date = view(box('Pick a date', mode='day', value='2021-10-10', range=('2019-01-01', '2022-12-31')))
view(f'You picked {date}.')

Screenshot

Handle changes immediately

Add live to mode to handle changes immediately.

date = '2021-10-10'
while True:
    date = view(
        box('Pick a date', mode='live day', value=date),
        f'You picked {date} (UTC).'
    )

Screenshot

Disable

Set disabled=True to disable.

view(box('Pick a date', mode='day', disabled=True))

Screenshot