UI Toolbox logoUI Toolbox

MonthCalendar and DatePicker

A MonthCalendar is a month grid: a header with the month and the previous and next buttons, a row of day names, six weeks of days and a footer with Today (and Clear in Range and Multiple mode). A DatePicker is a BaseField<DateTime>: a text input and a button that opens a MonthCalendar popup.

<UIToolbox.DatePicker label="Due" date="2026-09-24" />
<UIToolbox.DatePicker label="ISO" format="yyyy-MM-dd" min-date="2026-01-01" max-date="2026-12-31" />
<UIToolbox.DatePicker label="Starts" show-time="true" />
<UIToolbox.DatePicker label="Stay" range="true" date="2026-09-24" range-end="2026-09-30" />
<UIToolbox.MonthCalendar selection-mode="Range" show-week-numbers="true" />
<UIToolbox.MonthCalendar selection-mode="Range" month-count="2" />
// A range in one field, with a list of presets at the side of the calendar
var period = new DatePicker("Period") { Range = true };
period.Calendar.MonthCount = 2;
period.Presets = new[]
{
    new DatePreset("Today", () => DateTime.Today),
    new DatePreset("Last 7 days", () => (DateTime.Today.AddDays(-6), DateTime.Today)),
    new DatePreset("This month", () =>
    {
        var first = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
        return (first, first.AddMonths(1).AddDays(-1));
    })
};
period.RangeChanged += (start, end) => Debug.Log($"{start:d} to {end:d}");
MonthCalendar member Description
value The last picked date, without the time. Setting it shows its month. Listen with RegisterValueChangedCallback.
DateIso, MinDateIso, MaxDateIso (date, min-date, max-date) The value and the limits as ISO dates (yyyy-MM-dd).
MinDate, MaxDate The limits. The value and the shown month stay between them. In January of year 1 and December of year 9999, the cells outside the DateTime range are empty.
SelectionMode (selection-mode) Single (the value), Range (RangeStart, RangeEnd) or Multiple (SelectedDates). A change clears the selection.
FirstDayOfWeek The first column. Null (the default) uses the culture. Code only.
ShowWeekNumbers (show-week-numbers) Shows the week of the year, by the culture's week rule.
ShowTodayButton (show-today-button) Shows the Today button (true).
Culture The culture of the title, the day names and the weeks. The default is CultureInfo.CurrentCulture.
IsDateEnabled Returns false for dates the user cannot pick, for example weekends or holidays.
MonthCount (month-count) The months shown side by side, 1 (the default) to 12. With more than one, each month shows only its own days, the outer months have the arrows, and a pick in a later month does not move the months.
DisplayMonth, MonthChanged The first day of the shown month (the first one with MonthCount), and the event when it changes. The last shown month stays at or before the month of MaxDate.
View Days (the default), Months (the 12 months of a year) or Years (12 years). A click on the month title shows the months with the year on top. A click on the year shows the years. A click on a year, then on a month, goes back to the days. A new value shows the days.
Pick(date), DatePicked Picks a date as a click does, and the event for each pick, also a pick of the current value.
SelectionChanged, ClearSelection() The event when the range or the set of dates changes, and the call that clears them.
SetRange(start, end) Sets a complete range from code in Range mode, and shows the month of its start. The value stays.
RangePreviewEnd The other end of the range preview: the day under the pointer, or the keyboard cursor. Null outside Range mode, before the first pick and after the second.
TodayText, ClearText (today-text, clear-text) The button texts, such as "Heute" and "Löschen".
DatePicker member Description
value The date. Listen with RegisterValueChangedCallback.
Format (format) The .NET date format of the text. Empty uses "d" (the culture's short date), or "g" (the short date and time) with ShowTime.
ShowTime (show-time) Keeps the time of day in the value, and shows a TimeSpanPicker for hours and minutes under the calendar. Off, the value is the date only.
TimeInput The time field. Set its Format to HoursMinutesSeconds for seconds.
DateIso, MinDateIso, MaxDateIso, MinDate, MaxDate, Culture As on MonthCalendar. The limits go to the calendar.
Calendar The calendar in the popup. Set IsDateEnabled, ShowWeekNumbers or FirstDayOfWeek on it.
TodayText, TimeLabel (today-text, time-label) The text of the calendar Today button, and the label of the time field ("Time").
Open(), Close(), Toggle(), IsOpen The popup.
Range (range) The field holds a range (false). The value is the start, the text shows the start and the end, and the calendar takes two picks.
RangeEnd, RangeEndIso (range-end) The end of the range, and the same as an ISO date. It is never before the value. Without Range it is the value.
SetRange(start, end), RangeChanged Sets the start and the end, and the event when one of them changes, with both dates.
Presets A list of DatePresets. Each is a button at the side of the calendar. Code only.
DatePreset member Description
DatePreset(text, date) A preset of one date. The function runs at each click, so "Today" stays right.
DatePreset(text, range) A preset of a range: the function returns the start and the end.
Text, Range The text of the button, and the function.

Styling

Class Element
tb-month-calendar The calendar. The keyboard cursor shows only while it has focus.
tb-month-calendar__months, __month The row of shown months, and one month (small side padding).
tb-month-calendar__header, __nav, __title The header row, the previous and next buttons, and the month.
tb-month-calendar__body The area with the months. The Months and Years views lie over it, so the calendar keeps its size.
tb-month-calendar__zoom, __zoom-grid The Months or Years view, and its grid of 4 columns and 3 rows.
tb-month-calendar__cell, __cell--current, __cell--cursor A month or a year, the shown one (accent), and the keyboard cursor (a border while the calendar has focus).
tb-month-calendar__row The day-name row and each week row.
tb-month-calendar__day-name, __week A day name and a week number (muted, 11 px).
tb-month-calendar__day A day cell (28 x 24 px).
tb-month-calendar__day--other-month A day of the month before or after (faded).
tb-month-calendar__day--today Today (accent border).
tb-month-calendar__day--selected The value, the range ends, or a picked date (accent).
tb-month-calendar__day--in-range A day between the range ends (hover color).
tb-month-calendar__day--range-preview A day from the range start to the day under the pointer, before the second pick (as --in-range).
tb-month-calendar__day--weekend Saturday and Sunday (muted).
tb-month-calendar__day--disabled A day the user cannot pick (faded, not enabled).
tb-month-calendar__day--cursor The keyboard cursor.
tb-month-calendar__footer The row with Today and Clear.
tb-date-picker The field.
tb-date-picker__text, tb-date-picker__button The text input and the button.
tb-date-picker__popup The popup: a row with the calendar (and the time under it) and the presets.
tb-date-picker__presets, tb-date-picker__preset The column of presets at the side of the calendar, and one preset (a Button).
tb-date-picker__time The TimeSpanPicker under the calendar, with ShowTime.