Date Edit

RzDateEdit is a date input with a calendar popup, bound to a nullable DateTime model property through For. It must be placed inside an EditForm. The calendar is provided by Flatpickr, configured from the server with FlatpickrOptions; the rzDateEdit Alpine component loads Flatpickr and creates the picker. There is no Blazor interactivity: the input carries the same name as Blazor's own inputs (for example Model.StartDate), so the date is submitted with the form and binds to the model, and validation attributes from data annotations such as [Required] are added.

Basic Usage

Bind the component to a DateTime? property with For. The current value is shown in the input and preselected in the calendar.

Source
<EditForm Model="_model">
    <Field>
        <FieldLabel For="@(() => _model.StartDate)">Start date</FieldLabel>
        <RzDateEdit For="@(() => _model.StartDate)" Placeholder="Select a date" />
    </Field>
</EditForm>

@code {
    private readonly EventModel _model = new() { StartDate = new DateTime(2026, 11, 15) };

    private sealed class EventModel
    {
        public DateTime? StartDate { get; set; }
    }
}

Flatpickr Options

Pass a FlatpickrOptions object to Options to configure the calendar. This example shows dates as day/month/year with DateFormat (Flatpickr tokens; the server renders the value in the same format), limits the selectable range with MinDate and MaxDate, and adds a calendar icon with PrependIcon. Dates outside the range are disabled in the calendar.

Source
<EditForm Model="_model">
    <RzDateEdit For="@(() => _model.EndDate)"
                Options="@(new FlatpickrOptions { Locale = "en", DateFormat = "d/m/Y", MinDate = new DateTime(2026, 11, 1), MaxDate = new DateTime(2026, 12, 31) })"
                PrependIcon="MdiIcon.Calendar"
                Placeholder="November or December" />
</EditForm>

Loading with htmx

A date field can be loaded or replaced by an htmx request. Each time the button is used, the previous field is removed and its Flatpickr instance destroyed, so calendars do not accumulate in the page.

Page
<RzButton hx-get="/demo/date-edit-sample"
          hx-target="#date-edit-htmx-target"
          hx-swap="innerHTML">
    Load date field
</RzButton>
<div id="date-edit-htmx-target"></div>
Demo Content Page (/demo/date-edit-sample)
@page "/demo/date-edit-sample"
@layout EmptyLayout

<EditForm Model="_model">
    <RzDateEdit For="@(() => _model.Deadline)"
                Options="@(new FlatpickrOptions { Locale = "en", MinDate = new DateTime(2026, 11, 1), MaxDate = new DateTime(2026, 12, 31) })"
                Placeholder="Select a deadline" />
</EditForm>

Accessibility

The component renders a role="group" container labelled "Date picker" around a text input labelled "Select date". Keyboard support comes from Flatpickr. By default Flatpickr makes the input read-only; set AllowInput = true in FlatpickrOptions to let users type a date.

KeyEffect
Click or focus the inputOpens the calendar; focus stays on the input.
Down Arrow (on the input)Moves focus into the calendar, onto the selected day.
Left / Right Arrow (on a day)Previous / next day.
Up / Down Arrow (on a day)Same day of the previous / next week.
Enter (on a day)Selects the day, closes the calendar and returns focus to the input.
EscapeCloses the calendar without changing the value and returns focus to the input.

Component Parameters

PropertyDescriptionTypeDefault
For RequiredThe model property the date is bound to. The component must be inside an EditForm.Expression<Func<DateTime?>>null
OptionsFlatpickr configuration (for example DateFormat, MinDate, MaxDate, EnableTime, AllowInput). Dates are sent as ISO strings and converted to local dates before Flatpickr reads them, so they work with any DateFormat. DefaultDate is filled from the bound value when not set; the Options instance itself is not modified.FlatpickrOptionsnew() { Locale = "en" }
PlaceholderPlaceholder text for the input.string""
PrependTextText shown at the start of the input. Takes precedence over PrependIcon.string?null
PrependIconIcon shown at the start of the input.SvgIcon?null
ComponentAssetKeysKeys in RizzyUIConfig.AssetUrls for the scripts to load. With an empty array, Flatpickr must already be loaded by the page (window.flatpickr).string[]["FlatpickrCore"]

Alpine API

The rzDateEdit Alpine component has no public methods for application code and raises no events. Its lifecycle hooks are listed for reference.

MethodParametersDescription
init()—Reads data-config, loads the assets and creates the Flatpickr instance with a copy of the options.
destroy()—Called by Alpine when the element is removed. Destroys the Flatpickr instance, or prevents it from being created if the assets are still loading.