Skip to content

Datetime ​

Datetime is an inline month calendar for picking a single date.

IonDatetime is the calendar; IonDatetimeButton is a compact button that shows a formatted date (and optionally a time) and asks the app to open a datetime.

The Miko port implements only Ionic's calendar (date) view. There is no time wheel, no month/year wheel (the month/year label in the calendar header is not tappable), no min / max / disabled dates, no multiple selection, and no locale formatting — labels use the invariant culture (English).

Basic usage ​

Bind the selected date with @bind-Value. The value is an ISO date string (yyyy-MM-dd); a full ISO date-time is accepted on input, but only its date part is used and a selection always writes back yyyy-MM-dd. Tapping a day selects it immediately. The calendar opens on the month of Value, or the current month when Value is empty; the arrows in the header page between months. Today is outlined; the selected day is filled.

razor
<IonDatetime @bind-Value="_date" />

<p>Selected: @(_date ?? "nothing yet")</p>

@code {
    // ISO date string, "yyyy-MM-dd".
    private string? _date = "2026-07-15";
}

Title and buttons ​

The header with the title ("Select Date", not configurable) and the selected date (ShowDefaultTitle) is shown by default. ShowDefaultButtons="true" adds a Cancel / Done row (CancelText, DoneText). The buttons do not hold back the selection — Value has already changed when a day was tapped. OnConfirm receives the current value and OnCancel nothing, so to support Cancel keep the confirmed value yourself, as below.

razor
@* The value changes as soon as a day is tapped; Done / Cancel only raise events. *@
<IonDatetime @bind-Value="_draft"
             ShowDefaultTitle="false"
             ShowDefaultButtons="true"
             DoneText="Save"
             OnConfirm="Save"
             OnCancel="Revert" />

<p>Saved: @(_saved ?? "nothing yet")</p>

@code {
    private string? _saved;
    private string? _draft;

    private void Save(string? value) => _saved = value;

    private void Revert() => _draft = _saved;
}

First day of the week ​

FirstDayOfWeek sets the first column of the grid: 0 = Sunday (default), 1 = Monday, and so on.

razor
@* 0 = Sunday (default), 1 = Monday, … *@
<IonDatetime FirstDayOfWeek="1" @bind-Value="_date" />

@code {
    private string? _date;
}

Datetime button ​

In Ionic, ion-datetime-button finds its datetime by id, formats its value, and opens it. The Miko port has no such link: pass the text to show in DateText (and TimeText; each button renders only when its text is set) and open your own IonDatetime from OnDateClick / OnTimeClick, typically in an IonModal or IonPopover. DatetimeActive highlights the button while it is open (SelectedButton picks the date or the time button). The Datetime parameter is kept only for API parity.

razor
@* IonDatetimeButton only renders the formatted value and raises OnDateClick; the app opens its
   own IonDatetime, here in a modal, and closes it again. *@
<IonDatetimeButton DateText="@FormatDate(_date)" DatetimeActive="_isOpen"
                   OnDateClick="@(() => _isOpen = true)" />

<IonModal @bind-IsOpen="_isOpen">
    <IonDatetime @bind-Value="_date"
                 ShowDefaultButtons="true"
                 OnConfirm="@(_ => _isOpen = false)"
                 OnCancel="@(() => _isOpen = false)" />
</IonModal>

@code {
    private string? _date = "2026-07-15";
    private bool _isOpen;

    private static string FormatDate(string? value) =>
        DateTime.TryParse(value, out var date) ? date.ToString("MMM d, yyyy") : "Select date";
}

Disabled and read-only ​

Disabled dims the calendar and blocks every tap. Readonly blocks taps — day selection, month paging, and the footer buttons — but keeps the normal look. IonDatetimeButton also has Disabled.

API ​

Every component also accepts Class (extra CSS classes), Style (an inline Style object) and Id (the root element's id) — see Conventions.

IonDatetime ​

ParameterTypeDefaultDescription
CancelTextstring"Cancel"Cancel button label.
Colorstring?nullNamed palette color (Ionic color): "primary", "danger", …. Replaces the primary color of today's marker, the selected day, the action buttons and (md) the header.
DisabledboolfalseIf true, the datetime is dimmed and non-interactive.
DoneTextstring"Done"Confirm button label.
FirstDayOfWeekint0The first day of the week (0 = Sunday, default). Ionic firstDayOfWeek.
ReadonlyboolfalseIf true, the datetime is non-interactive but not dimmed.
ShowDefaultButtonsboolfalseIf true, the footer Cancel / Done buttons are shown. They only raise OnCancel / OnConfirm; the value already changed when the day was tapped.
ShowDefaultTitlebooltrueIf true (default), the header title/selected-date is shown.
Valuestring?nullThe selected value as an ISO date string (yyyy-MM-dd). Bind two-way with ValueChanged. Two-way bindable: @bind-Value.
EventTypeDescription
OnCancelEventCallbackRaised when the cancel button is tapped.
OnConfirmEventCallback<string?>Raised when the confirm button is tapped, with the selected ISO date.
ValueChangedEventCallback<string?>Raised with the new ISO date string when a day is selected.

IonDatetimeButton ​

ParameterTypeDefaultDescription
Colorstring?nullNamed palette color (Ionic color): "primary", "danger", …. The text color of the active button (see DatetimeActive), primary by default.
DateTextstring?nullThe formatted date label; when empty the date button is not rendered.
DatetimeActiveboolfalseWhether the associated datetime is currently open (stamps {selected}-active).
DisabledboolfalseIf true, the buttons are dimmed and non-interactive.
SelectedButtonstring"date"Which button reads as active while the datetime is open: "date" or "time".
TimeTextstring?nullThe formatted time label; when empty the time button is not rendered.
EventTypeDescription
OnDateClickEventCallbackRaised when the date button is tapped.
OnTimeClickEventCallbackRaised when the time button is tapped.

Styling ​

Theme tokens ​

Theme token IonicTheme.Datetime (DatetimeToken). Assign only the values you want to change — the rest keep the mode defaults below. App-wide: builder.AddIonic(o => o.Theme.Datetime = new DatetimeToken { … }); for one subtree: a ConfigProvider. See Theming.

TokenTypemdios
BackgroundColor#ffffff#f4f5f8
ButtonActiveColorColor#0054e9#0054e9
ButtonBackgroundColor#edeef0#edeef0
ButtonBorderRadiusfloat88
ButtonColorColor#000000#000000
ButtonFontSizefloat1616
ButtonPaddingXfloat1213
ButtonPaddingYfloat67
DayActiveBackgroundColor#0054e9rgba(0, 84, 233, 0.2)
DayActiveColorColor#ffffff#0054e9
DayColorColor#000000#000000
DayFontSizefloat1420
DayOfWeekColorColor#808080#808080
DayOfWeekFontSizefloat1412
DaySizefloat4240
HeaderBackgroundColor#0054e9#f4f5f8
HeaderColorColor#ffffff#000000
MonthYearColorColor#595959#000000
SelectedDateFontSizefloat3416
TitleFontSizefloat1214
TodayColorColor#0054e9#0054e9

CSS classes ​

App stylesheet rules always win over Ionic's own rules (see Theming), so these classes can be targeted directly from GlobalStyles.cs.

SelectorElement
.ion-datetimeThe host. Also carries the mode (md / ios) and the classes below.
.datetime-presentation-date, .datetime-size-fixedAlways on the host: the date grid at its fixed size is the one view that is ported.
.datetime-disabled, .datetime-readonlyDisabled, Readonly.
.ion-datetime .datetime-headerThe title area; holds .datetime-title and .datetime-selected-date.
.ion-datetime .calendar-action-buttonsThe month/year label (.calendar-month-year-toggle) and the paging buttons (.calendar-nav-button).
.ion-datetime .calendar-days-of-week .day-of-weekOne weekday label.
.ion-datetime .calendar-month-gridThe day grid (seven columns, wrapping).
.ion-datetime .calendar-dayOne day button; .calendar-day-padding for the blank cells before the 1st.
.calendar-day-today, .calendar-day-activeToday, the selected day.
.ion-datetime .datetime-footer, .datetime-action-buttonThe Cancel / Done row and its buttons.
.ion-datetime-buttonThe datetime button host; its buttons are #date-button and #time-button.
.date-active, .time-active, .datetime-button-disabledDatetimeActive with SelectedButton, Disabled.
csharp
// GlobalStyles.cs — square day cells
[".ion-datetime .calendar-day"] = new()
{
    BorderRadius = new BorderRadius(8),
},

Released under the MIT License.