Date Picker

Date Picker is an interactive component that allows users to select a date (and optionally time) from a visual calendar interface. It simplifies the process of choosing dates, improves accuracy, and ensures consistency in formatting.

Quick Start

Basic FodDatePicker with Label, Placeholder, and two-way binding.

Basic DatePicker

Selected: -

With pre-selected value

Value: 15/05/1990

With helper text

Select your preferred date
razor
<FodDatePicker Label="Select date"
               Placeholder="Choose a date"
               @bind-Value="_selectedDate" />

<FodDatePicker Label="Birth date"
               @bind-Value="_birthDate" />

Picker Types

Basic mode shows simple month/year header. Advanced mode provides month and year dropdown buttons for quick navigation.

Basic (default)

Advanced

razor
<FodDatePicker Label="Date"
               PickerType="DatePickerType.Basic"
               @bind-Value="_date" />

<FodDatePicker Label="Date"
               PickerType="DatePickerType.Advanced"
               @bind-Value="_date" />

Date Range Picker

Select a date range with visual selection highlighting in the calendar.

Basic date range

No range selected

Advanced date range

razor
<FodDateRangePicker Label="Select date range"
                    @bind-StartDate="_startDate"
                    @bind-EndDate="_endDate" />

<FodDateRangePicker Label="Vacation dates"
                    PickerType="DatePickerType.Advanced"
                    @bind-StartDate="_startDate"
                    @bind-EndDate="_endDate" />

Date Constraints

Restrict date selection with min/max dates, disabled days of week, or custom disabled dates function.

Min/Max dates (next 30 days)

Only future dates up to 30 days

Disabled weekends

Weekends are disabled

Custom disabled dates

Holidays are disabled
razor
<FodDatePicker Label="Appointment"
               MinDate="DateTime.Today"
               MaxDate="DateTime.Today.AddDays(30)"
               @bind-Value="_date" />

<FodDatePicker Label="Business date"
               DisabledDaysOfWeek="@(new[] { DayOfWeek.Saturday, DayOfWeek.Sunday })"
               @bind-Value="_date" />

<FodDatePicker Label="Available date"
               DisabledDates="@IsHoliday"
               @bind-Value="_date" />

@code {
    private bool IsHoliday(DateTime date) =>
        (date.Month == 1 && date.Day == 1) ||
        (date.Month == 12 && date.Day == 25);
}

States

FodDatePicker supports default, disabled, readonly, and error states.

Default

Disabled

Cannot be modified

ReadOnly

View only

Required with error

razor
<FodDatePicker Label="Date" Disabled="true" />
<FodDatePicker Label="Date" ReadOnly="true" />
<FodDatePicker Label="Date" Required="true" ErrorText="Required" />

Form Validation

FodDatePicker integrates with FodForm for validation. Supports Required validation, custom validation functions, and Data Annotations.

FodForm integration with validation

Must be a future date
Must be before event date
Leave empty if no preference
razor
<FodForm Model="@_formModel"
         ValidationMode="ValidationMode.OnBlur"
         ShowValidationSummary="true"
         OnValidSubmit="HandleFormSubmit">
    <ChildContent>
        <DataAnnotationsValidator />
        <FodDatePicker Label="Event date"
                       Required="true"
                       For="@(() => _formModel.EventDate)"
                       MinDate="DateTime.Today"
                       @bind-Value="_formModel.EventDate" />
        <FodDatePicker Label="Deadline"
                       Required="true"
                       For="@(() => _formModel.Deadline)"
                       MaxDate="@_formModel.EventDate"
                       @bind-Value="_formModel.Deadline" />
    </ChildContent>
    <Actions>
        <FodButton HtmlType="submit" Type="FodColor.Primary">Submit</FodButton>
    </Actions>
</FodForm>

@code {
    private class EventFormModel
    {
        [Required(ErrorMessage = "Event date is required")]
        public DateTime? EventDate { get; set; }

        [Required(ErrorMessage = "Deadline is required")]
        public DateTime? Deadline { get; set; }
    }
}

Localization & Formatting

Customize date format and culture for international applications.

Romanian (ro-RO)

Russian (ru-RU)

Custom format (yyyy-MM-dd)

Week starts on Monday

razor
<FodDatePicker Label="Data"
               Culture="@(new CultureInfo("ro-RO"))"
               TodayButtonText="Astazi"
               @bind-Value="_date" />

<FodDatePicker Label="Date"
               Format="yyyy-MM-dd"
               @bind-Value="_date" />

<FodDatePicker Label="Date"
               FirstDayOfWeek="DayOfWeek.Monday"
               @bind-Value="_date" />

Calendar Options

Customize calendar behavior and footer buttons.

With footer buttons

Today and Clear buttons shown

Only Today button

Not clearable

No clear button in input

Don't close on select

Calendar stays open
razor
<FodDatePicker Label="Date"
               ShowTodayButton="true"
               ShowClearButton="true"
               @bind-Value="_date" />

<FodDatePicker Label="Date"
               Clearable="false"
               @bind-Value="_date" />

<FodDatePicker Label="Date"
               CloseOnSelect="false"
               @bind-Value="_date" />

Full Width

DatePicker can expand to fill its container width.

Expands to fill container width
razor
<FodDatePicker Label="Full width" FullWidth="true" />

Accessibility & Keyboard Navigation

FodDatePicker follows WCAG AA accessibility guidelines with full keyboard support.

  • Tab/Shift+Tab: Navigate between input and calendar elements
  • Enter/Space: Select the focused date
  • Arrow keys: Navigate between days in the calendar
  • Page Up/Down: Navigate to previous/next month
  • Shift + Page Up/Down: Navigate to previous/next year
  • Home/End: Move to start/end of the week
  • Escape: Close the calendar popup
  • Arrow Down (from input): Open and focus the calendar
razor
<FodDatePicker Label="Accessible date picker"
               @bind-Value="_date" />

API Reference

FodDatePicker component properties and their descriptions.

No properties defined.

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please reload the page.