Skip to main content

CalendarView

A Fluent calendar that is always shown, for viewing and selecting dates. The user can switch between the days of a month, the months of a year and the years of a decade.

Example:

fluent.CalendarView(value=date(2025, 5, 14), width=300)
CalendarView
CalendarView

Inherits: LayoutControl

Properties

Events

  • on_change - Called when the user changes the selection.

Example​

Fluent CalendarView​

Sourceplay_arrowTry Online
from datetime import date

import flet_fluent_ui as fluent

import flet as ft


def main(page: ft.Page):
page.title = "Fluent CalendarView"

def handle_change(e: fluent.CalendarViewChangeEvent):
start, end = e.control.value, e.control.end_value
if start is None:
status.value = "Pick the first day of your trip"
elif end is None:
status.value = "Now pick the last day"
else:
# Picked dates arrive in UTC: convert them to local dates.
days = (end.astimezone() - start.astimezone()).days + 1
status.value = f"Your trip is {days} days long"

status = ft.Text("Your trip is 5 days long")

page.add(
ft.SafeArea(
content=ft.Column(
controls=[
fluent.CalendarView(
key="calendar",
width=300,
selection_mode=fluent.CalendarSelectionMode.RANGE,
value=date(2025, 5, 12),
end_value=date(2025, 5, 16),
# The office is closed on these days.
blackout_dates=[date(2025, 5, 1), date(2025, 5, 26)],
on_change=handle_change,
),
status,
],
)
)
)


if __name__ == "__main__":
ft.run(main)
calendar_view
Selecting a range

Properties​

blackout_datesclass-attributeinstance-attribute​

blackout_dates: list[DateTimeValue] = field(
    default_factory=list
)

Dates that can't be selected, such as holidays. They are shown struck through.

display_modeclass-attributeinstance-attribute​

What the calendar shows at first: the days of a month, the months of a year or the years of a decade.

end_valueclass-attributeinstance-attribute​

end_value: DateTimeValue | None = None

The end of the selected range, when selection_mode is RANGE.

first_dateclass-attributeinstance-attribute​

first_date: DateTimeValue | None = None

The earliest date that can be selected. Earlier dates are shown greyed out.

first_day_of_weekclass-attributeinstance-attribute​

first_day_of_week: int | None = None

The day the weeks start on: 1 for Monday through 7 for Sunday.

If None, it depends on the locale.

highlight_todayclass-attributeinstance-attribute​

highlight_today: bool = True

Whether today's date is highlighted.

last_dateclass-attributeinstance-attribute​

last_date: DateTimeValue | None = None

The latest date that can be selected. Later dates are shown greyed out.

selection_colorclass-attributeinstance-attribute​

selection_color: ColorValue | None = None

The color of selected dates.

If None, the accent color of the theme is used.

selection_modeclass-attributeinstance-attribute​

How many dates the user can select.

In MULTIPLE mode, value and end_value hold the first and last selected dates, and preselect up to two dates when set.

valueclass-attributeinstance-attribute​

value: DateTimeValue | None = None

The selected date, or the start of the selected range when selection_mode is RANGE.

After the user picks a date, it holds a datetime in UTC for midnight local time: use value.astimezone() to get the local date.

Events​

on_changeclass-attributeinstance-attribute​

on_change: (
    EventHandler[CalendarViewChangeEvent] | None
) = None

Called when the user changes the selection.

value and end_value hold the first and last selected dates, and the event's selected_dates all of them.