Skip to content
GitHub11 stars

A calendar component that allows users to select a date or a range of dates.

December 2026
<Calendar Mode="CalendarMode.Single" @bind-Selected="_date" Class="rounded-lg border" CaptionLayout="CalendarCaptionLayout.Dropdown" />

@code {
    private DateOnly? _date = DateOnly.FromDateTime(DateTime.Today);
}

Installation

dnx Blazix.Cli add calendar

Usage

<Calendar Mode="CalendarMode.Single" @bind-Selected="_date" Class="rounded-lg border" />

@code {
    private DateOnly? _date = DateOnly.FromDateTime(DateTime.Today);
}

The component is a Razor port of React DayPicker. Its documentation covers the markup, styling hooks, and keyboard behavior reproduced here.

About

The Calendar component reproduces the markup, class names, and keyboard navigation of React DayPicker, without a JavaScript dependency.

Date Picker

You can use the <Calendar> component to build a date picker. See the Date Picker page for more information.

Persian / Hijri / Jalali Calendar

Not supported. The calendar uses the Gregorian calendar.

Selected Date (With TimeZone)

The Calendar component accepts a TimeZone parameter (a system time zone id) to decide which day is today. Selected values are DateOnly, so they never shift with the time zone.

<Calendar Mode="CalendarMode.Single" @bind-Selected="_date" TimeZone="America/New_York" />

@code {
    private DateOnly? _date;
}

Basic

A basic calendar component. We used Class="rounded-lg border" to style the calendar.

December 2026
<Calendar Mode="CalendarMode.Single" Class="rounded-lg border" />

Range Calendar

Use Mode="CalendarMode.Range" to enable range selection.

January 2026
February 2026
<Calendar Mode="CalendarMode.Range" DefaultMonth="@_dateRange?.From" @bind-SelectedRange="_dateRange" NumberOfMonths="2" Class="rounded-lg border" />

@code {
    private static readonly DateOnly From = new(DateTime.Today.Year, 1, 12);
    private DateRange? _dateRange = new(From, From.AddDays(30));
}

Month and Year Selector

Use CaptionLayout="CalendarCaptionLayout.Dropdown" to show month and year dropdowns.

December 2026
<Calendar Mode="CalendarMode.Single" CaptionLayout="CalendarCaptionLayout.Dropdown" Class="rounded-lg border" />

Presets

December 2026
<Card Class="mx-auto w-fit max-w-[300px]" Size="CardSize.Sm">
    <CardContent>
        <Calendar Mode="CalendarMode.Single" @bind-Selected="_date" Month="_currentMonth" MonthChanged="month => _currentMonth = month"

Date and Time Picker

December 2026
<Card Size="CardSize.Sm" Class="mx-auto w-fit">
    <CardContent>
        <Calendar Mode="CalendarMode.Single" @bind-Selected="_date" Class="p-0" />

Booked dates

January 2026
<Card Class="mx-auto w-fit p-0">
    <CardContent Class="p-0">
        <Calendar Mode="CalendarMode.Single" DefaultMonth="_date" @bind-Selected="_date" Disabled="IsBooked"

Custom Cell Size

December 2026
@using System.Globalization
<Card Class="mx-auto w-fit p-0">
    <CardContent Class="p-0">

You can customize the size of calendar cells using the --cell-size CSS variable. You can also make it responsive by using breakpoint-specific values:

<Calendar Mode="CalendarMode.Single" @bind-Selected="_date"
          Class="rounded-lg border [--cell-size:--spacing(11)] md:[--cell-size:--spacing(12)]" />

Or use fixed values:

<Calendar Mode="CalendarMode.Single" @bind-Selected="_date"
          Class="rounded-lg border [--cell-size:2.75rem] md:[--cell-size:3rem]" />

Week Numbers

Use ShowWeekNumber to show week numbers.

January 2026
01
02
03
04
05
<Card Class="mx-auto w-fit p-0">
    <CardContent Class="p-0">
        <Calendar Mode="CalendarMode.Single" DefaultMonth="_date" @bind-Selected="_date" ShowWeekNumber />
    </CardContent>
</Card>

@code {
    private DateOnly? _date = new(DateTime.Today.Year, 1, 12);
}

RTL

To enable RTL support in Blazix, see the RTL configuration guide.

Translated with AI for the demo, so it may have mistakes.

ديسمبر 2026

// The preview sets dir and lang around this example, as your app sets them on <html>. // It uses components added with "rtl": true. See the RTL guide.

@* Month and day names come from Locale; dir="rtl" around it (or a DirectionProvider) swaps Left and Right. *@
<Calendar Mode="CalendarMode.Single" @bind-Selected="_date" Locale="@Language.Culture"
          Class="rounded-lg border [--cell-size:--spacing(9)]" CaptionLayout="CalendarCaptionLayout.Dropdown" />

@code {
    [CascadingParameter] private Language Language { get; set; } = Language.Arabic;

    private DateOnly? _date = DateOnly.FromDateTime(DateTime.Today);
}

API Reference

Calendar

ParameterTypeDefault
Mode CalendarMode? -
FormatMonthDropdown Func<DateOnly, string>? -
TimeZone string? -
Locale CultureInfo? -
ButtonVariant ButtonVariant ButtonVariant.Ghost
CaptionLayout CalendarCaptionLayout CalendarCaptionLayout.Label
ShowWeekNumber bool false
FixedWeeks bool false
ShowOutsideDays bool true
NumberOfMonths int 1
EndMonth DateOnly? -
StartMonth DateOnly? -
DayButton RenderFragment<CalendarDayButtonProps>? -
DefaultMonth DateOnly? -
Month DateOnly? -
ModifiersClassNames IReadOnlyDictionary<string, string>? -
Modifiers IReadOnlyDictionary<string, Func<DateOnly, bool>>? -
Disabled Func<DateOnly, bool>? -
Required bool false
SelectedRangeChanged EventCallback<DateRange?> -
SelectedRange DateRange? -
SelectedDatesChanged EventCallback<IReadOnlyList<DateOnly>?> -
SelectedDates IReadOnlyList<DateOnly>? -
SelectedChanged EventCallback<DateOnly?> -
Selected DateOnly? -
MonthChanged EventCallback<DateOnly> -
Class string? -

Other attributes are passed to the element it renders.

CalendarDayButton

ParameterTypeDefault
Day CalendarDay -
Modifiers CalendarModifiers -
Locale CultureInfo? -
Disabled bool false
Type ButtonType ButtonType.Button
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.