Calendar

Report on GitHub

Calendar basics

Month view with an arrow header for navigation.

today_* marks the current date (rendered with the today highlight). shown_* controls which month the calendar opens on — here we start a month behind today so the user immediately sees that the today indicator only fires when the shown month matches. A <header_arrow/> child adds prev/next arrows to the top of the calendar; swap it for <header_dropdown/> to get the month/year selector variant.

Chinese calendar mode

Render a calendar with Chinese lunar annotations for March 2024.

A 300x300 lv_calendar is aligned to the top center of the active screen with today set to 2024-03-22 via lv_calendar_set_today_date and the shown month fixed by lv_calendar_set_month_shown. An arrow or dropdown header is attached when available. lv_calendar_set_chinese_mode enables lunar labels and the CJK font lv_font_source_han_sans_sc_14_cjk is applied on LV_PART_MAIN. When the Chinese calendar is disabled the example falls back to a centered "not enabled" label.

Calendar with highlighted days

Show February 2021 with three highlighted dates and log the tapped day.

A 185x230 lv_calendar is placed below screen center with today set to 2021-02-23 via lv_calendar_set_today_date and the shown month fixed by lv_calendar_set_month_shown. A static array of three lv_calendar_date_t entries is registered through lv_calendar_set_highlighted_dates. The LV_EVENT_VALUE_CHANGED callback reads lv_calendar_get_pressed_date and logs the tapped day. If LV_USE_CALENDAR_HEADER_DROPDOWN or _ARROW is available the matching header is attached.

Last updated on

On this page