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. |
- In the calendar, Left and Right move one day, Up and Down one week, Page Up and Page Down one month, Home and End to the first and last day of the month. The gamepad directions move as the arrows. The keys skip dates that the user cannot pick. Tab leaves the calendar.
- Ctrl+Up shows the wider view (the months, then the years). In those views the arrows move a cursor, also to the year or the 12 years before and after, Page Up and Page Down change the year or the 12 years, and Enter, Space or Ctrl+Down opens the month or the year of the cursor.
- The months and the years outside
MinDateandMaxDateare disabled. The Months and Years views do not change the value: only a click on a day does. - The
DatePickerpopup has the same views. - In Single mode the keys change the value. In Range and Multiple mode they move a cursor, and Enter or Space picks it.
- In Range mode the first pick sets the start, the second the end (the two are put in order), and a third starts a new range. In Multiple mode a pick adds or removes a date.
- The DatePicker popup shows in the nearest
Workspace, as theSearchDropdownpopup does. Down in the text opens it. A pick, Escape or a click outside closes it. WithShowTime, a pick keeps the time and the popup stays open, and a time change applies at once. In the popup the keys move the calendar only; Enter picks. - With
Range, the popup shows the range of the field. The first pick is the new start and the popup stays open. The second pick is the end, the two are put in order, and the popup closes. A change of the start is aChangeEvent; a change of the start or the end is aRangeChanged. - The range text is the two dates with " – " between them. A typed range can also have " - ". Both dates must be dates that the user can pick. A range has no time:
ShowTimeis not used. - A click on a preset sets its date (without
Range, the start of its range), or its range, and closes the popup. Tab moves from the calendar to the presets, and Enter or Space picks one. A gamepad does not reach the presets. - Set
Calendar.MonthCountto 2 for a range across a month end. - A typed text that is not a date in
Culture, or a date the user cannot pick, is ignored, and the text shows the value again. The text's own change event stops in the picker. - UXML dates are strings. A
DateTimeUXML attribute needs a converter that is editor-only, and Unity cannot serializeDateTime, so the value would be lost at runtime. - Saturday and Sunday get the weekend class in every culture.
- In Range mode, after the first pick, the days from the start to the day under the pointer get the
--range-previewclass. It looks like the range. When the pointer leaves the calendar, the keyboard cursor is the other end, so the arrows also show the preview. The second pick ends the preview. - The month and day names come from
Culture. Set the button texts for other languages; the arrows "‹" and "›" have no text to translate.
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. |