Skip to content
Form InputDate

InputDate

A date field typed in segments with a calendar popover. The value is always posted as yyyy-MM-dd.

On this page

Examples

Bound

Selected: none

Razor
<div class="flex w-full max-w-xs flex-col gap-3">
    <KlyFormField Label="Birthday">
        <KlyInputDate @bind-Value="_date" Max="new DateOnly(2026, 12, 31)" data-testid="birthday" />
    </KlyFormField>
    <p class="text-sm text-(--klyroo-text-muted)" data-testid="birthday-state">Selected: @(_date?.ToString("yyyy-MM-dd") ?? "none")</p>
</div>

@code {
    private DateOnly? _date;
}

In an EditForm

Posts in static rendering too: the input is the browser's own date input.

Posted as yyyy-MM-dd.

Razor
<EditForm Model="Model" FormName="appointment" OnValidSubmit="Save" class="flex w-full max-w-xs flex-col items-start gap-3">
    <KlyFormField Label="Appointment date" Description="Posted as yyyy-MM-dd." Field="FieldIdentifier.Create(() => Model!.Date)" class="w-full">
        <KlyInputDate @bind-Value="Model!.Date" data-testid="appointment" />
    </KlyFormField>
    <KlyButton Type="ButtonType.Submit" Label="Book" />
    @if (_saved)
    {
        <p role="status" class="text-sm text-(--klyroo-success-text)" data-testid="appointment-saved">Booked: @Model!.Date?.ToString("yyyy-MM-dd")</p>
    }
</EditForm>

@code {
    [SupplyParameterFromForm(FormName = "appointment")]
    private Booking? Model { get; set; }

    private bool _saved;

    protected override void OnInitialized() => Model ??= new() { Date = new DateOnly(2026, 11, 10) };

    private void Save() => _saved = true;

    private sealed class Booking
    {
        public DateOnly? Date { get; set; }
    }
}

Bound to DateTime and DateTimeOffset?

The field binds to a DateOnly, a DateTime or a DateTimeOffset, nullable or not. Picking a day keeps the time of day and the offset of the value, and a value that was null starts at midnight; Min and Max stay days (DateOnly).

Due: 2026-12-15, shipped: null

Razor
<div class="flex w-full max-w-xs flex-col gap-4">
    <KlyFormField Label="Due (DateTime)">
        <KlyInputDate @bind-Value="_due" Min="DateOnly.FromDateTime(_today)" data-testid="due" />
    </KlyFormField>
    <KlyFormField Label="Shipped (DateTimeOffset?, can be empty)">
        <KlyInputDate @bind-Value="_shipped" data-testid="shipped" />
    </KlyFormField>
    <p class="text-sm text-(--klyroo-text-muted)" data-testid="typed-date-state">Due: @_due.ToString("yyyy-MM-dd"), shipped: @(_shipped?.ToString("yyyy-MM-dd") ?? "null")</p>
</div>

@code {
    private static readonly DateTime _today = new(2026, 11, 26);

    // The field binds to a DateOnly, a DateTime or a DateTimeOffset, nullable or not. Picking a day keeps the time of day (and offset) of the value; a value that was null starts at midnight.
    private DateTime _due = new(2026, 12, 15);
    private DateTimeOffset? _shipped;
}

API

KlyInputDate<TValue>

Date field with a calendar popup, with localized formatting. It binds to a DateOnly , a DateTime or a DateTimeOffset , or to the nullable form of one of them. Picking a day keeps the time of day of the current value (and the kind of a DateTime , the offset of a DateTimeOffset ); a value that had none (null before, or the default) starts at midnight, a DateTimeOffset in the offset of the server's local time zone on that day.

Parameters

Name Type Default Description
Class string Classes added to the root element, merged last so they win over the theme.
Color KlyColor "primary" Semantic color of the control: a built-in KlyColor or the name of a color you defined. When not set, Color applies, else primary. Values: primary, secondary, success, info, warning, error, neutral.
Culture CultureInfo Source of the calendar's month and day names. Defaults to the format culture of the locale in effect (the regional current culture when it has the same language).
Disabled bool false Disables the control: it cannot be focused or changed and is not submitted.
Id string The id of the native control. Defaults to the one of the enclosing KlyFormField , else a generated one.
Max DateOnly? Latest date, for the input and the calendar.
Min DateOnly? Earliest date, for the input and the calendar. A day ( DateOnly ) whatever the bound type: use DateOnly.FromDateTime(...) to limit a DateTime field.
Name string Form field name outside an EditForm . Inside one, the name comes from the bound expression.
Required bool false Marks the control as required, for the browser and for assistive technology.
Size KlySize? Defaults to the size of the enclosing KlyFormField , or medium. Values: Xs, Sm, Md, Lg, Xl.
Ui InputDateUi Per-instance class overrides of the slots of the input date, see InputDateUi . They are merged after the theme and the Class parameter wins on the root slot.
Value (@bind-Value) TValue The value of the control. Bind it with @bind-Value .
ValueExpression Expression<Func<TValue>> The expression of the bound field. The compiler sets it with @bind-Value , and validation uses it to find the field.
Variant FieldVariant FieldVariant.Outline Look of the field: Outline , Soft , Subtle , Ghost or None . Values: Outline, Soft, Subtle, Ghost, None.
WeekStart DayOfWeek? First column of the calendar. Defaults to the culture's first day of the week. Values: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday.

Ui slots

Ui takes a InputDateUi with one class string per slot, merged after the theme.

Slot Styles
Root Classes merged into the root slot of KlyInputDate`1 , after the theme and the app configuration.
Base Classes merged into the base slot of KlyInputDate`1 , after the theme and the app configuration.
Trigger Classes merged into the trigger slot of KlyInputDate`1 , after the theme and the app configuration.
TriggerButton Classes merged into the triggerButton slot of KlyInputDate`1 , after the theme and the app configuration.
TriggerIcon Classes merged into the triggerIcon slot of KlyInputDate`1 , after the theme and the app configuration.
Content Classes merged into the content slot of KlyInputDate`1 , after the theme and the app configuration.