Skip to main content

Calendar

Calendar is the month-view date grid in the authoring widget set.

It is the lower-level calendar surface that powers date-picking flows. Your app provides the current year and month, the optionally selected date, and callbacks for both day selection and month navigation. This explicit model matters because calendars usually mix product rules with user interface rules: what month is shown, what day is selected, and what navigation is allowed.

Example

use chrono::NaiveDate;
use fission::prelude::*;
use std::sync::Arc;

let node = Calendar {
year: view.state.visible_year,
month: view.state.visible_month,
selected_date: view.state.selected_day,
on_select: Some(Arc::new(move |date: NaiveDate| ActionEnvelope {
id: set_selected_day_id,
payload: serde_json::to_vec(&SetSelectedDay(date)).unwrap(),
})),
on_navigate: Some(Arc::new(move |year, month| ActionEnvelope {
id: set_visible_month_id,
payload: serde_json::to_vec(&SetVisibleMonth { year, month }).unwrap(),
})),
cell_size: Some(40.0),
padding: Some(16.0),
}
.build(ctx, view);

The reducer usually stores both the selected day and the currently visible month. Those are related, but they are not always the same thing.

Field table

FieldTypeMeaningNotes / default behavior
yeari32Year shown in the current month view.Required.
monthu32Month shown in the current month view.Required. Expected range is 1..=12.
selected_dateOption<NaiveDate>Currently selected day, if any.Defaults to None.
on_selectOption<Arc<dyn Fn(NaiveDate) -> ActionEnvelope + Send + Sync>>Closure that builds the action for a picked day.Called when the user presses a day cell.
on_navigateOption<Arc<dyn Fn(i32, u32) -> ActionEnvelope + Send + Sync>>Closure that builds the action for previous or next month.Called with the new (year, month) pair.
cell_sizeOption<f32>Width and height of each day cell.Defaults to 36.0. Use smaller sizes in sidebars and larger ones in full panels.
paddingOption<f32>Outer padding around the calendar surface.Defaults to 16.0.

State ownership and practical limits

Calendar does not compute product rules such as unavailable dates, range constraints, or locale-specific week starts. The checked-in implementation is Sunday-first, uses single-letter weekday headings, and highlights today using the host's local date.

That makes it a good general month picker, but if your product needs Monday-first weeks, blocked dates, or complex business calendars, plan on wrapping or extending the widget rather than assuming those rules are built in.

Specific advice

Keep visible-month state explicit even when a date is selected. Users often need to look at another month without committing a new date yet.

DatePicker, DateRangePicker, TimePicker, and Pagination.