Skip to main content

Module calendar

Module calendar 

Source
Expand description

Calendar — month-grid date picker, standalone widget.

A self-contained calendar with month/year navigation, a 6×7 day grid, keyboard navigation matching the WAI-ARIA grid pattern, and full AccessKit instrumentation (Role::Grid + per-cell Role::GridCell). Used standalone for event apps and scheduling, and embedded in DateEdit’s popover.

§Selection modes

  • Calendar::single — pick one day. Bound to Signal<Option<Date>>.
  • Calendar::range — pick a start + end day. Bound to Signal<Option<DateRange>>. Click first day → click second day to commit. Escape mid-selection cancels the in-progress anchor.

§Behaviour

  • Visible month is independent of the selection — navigating past the selected month doesn’t lose the selection.
  • Today highlight draws a ring around today’s cell whenever it’s in the visible month. Color comes from TextRole::Accent.
  • Out-of-month cells (the leading days from the previous month and trailing days from the next month that fill the 6×7 grid) are rendered with TextRole::Disabled and remain selectable (matching macOS / Material). To prevent selection use disabled_date_filter.
  • Keyboard (matches the WAI-ARIA grid pattern):
    • Arrow keys: move focus by one day.
    • Home / End: first / last day of week.
    • Ctrl+Home / Ctrl+End: first / last day of month.
    • PageUp / PageDown: previous / next month.
    • Shift+PageUp / Shift+PageDown: previous / next year.
    • Enter / Space: commit focused day to selection.
    • Escape: in range mode mid-selection, cancel anchor; otherwise bubble (popover hosts close).
    • T: jump focus to today.

§Accessibility

  • Container — Role::Grid with set_label("Calendar, May 2026") (localized). Single-mode also sets set_value to the current ISO selection or empty; range mode sets "start – end".
  • Header arrow buttons — Role::Button with localized labels (“Previous month”, “Next month”) and Action::Click advertised.
  • Header month/year label — Role::Button (clickable to open the month picker) with set_has_popup(HasPopup::Grid) and set_expanded(open).
  • Weekday header row — Role::Row of Role::ColumnHeader cells, each labelled with the long weekday name (e.g. “Monday”).
  • Day cells — Role::GridCell with localized long-form labels (“May 2, 2026”), set_selected, set_focused, set_disabled for filter rejections, and Action::Click advertised.

§Example

use teksilo::widgets::{Calendar, common::datetime::Date};

let date = ctx.signal(Some(Date::constant(2026, 5, 2)));
ctx.add(
    Calendar::single(date.clone())
        .show_today_button(true)
        .on_selection_changed(|d, ctx| ctx.send_intent(MyIntent::DateChanged(d))),
);

Structs§

Calendar
Standalone month-grid date picker. See the module docs for the full feature list and a usage example.
DateRange
Inclusive range of two dates, with start <= end enforced at construction. Used by Calendar::range.

Enums§

CalendarMode
What the calendar body is showing — drives the WPF/Avalonia “header-zoom” UX where clicking the title cycles to a coarser grid, letting the user reach any year in 2-3 clicks instead of many chevron presses. Default CalendarMode::Days.
WeekNumberDisplay
Whether and how week numbers are displayed in the leading column of the day grid.