Showcase

Blazor Calendar

The Blazor Bootstrap Calendar component is an event calendar with Month, Week, Work week, Day, and Agenda views. The examples below cover navigation, event kinds, week, work week, and day, time grid settings and drag to select, move, and resize.
API Documentation
INFO
Bootstrap 5.3 has no calendar component. Calendar is built from Bootstrap classes (buttons, button groups, text-bg-* colors) and a small set of --bb-calendar-* CSS properties, so it follows the light and dark themes. Your app binds a list of events and reacts to callbacks; the calendar never changes an event itself.
Move through time with previous, next, and Today, and switch between the Month, Week, Work week, Day, and Agenda views. The title shows the visible period. Select the title to open a small month grid and jump to any date.
How to use:
  1. Add Calendar and set TItem to your event type.
  2. Bind View (CalendarView) and Date with @bind-View and @bind-Date to read or set what the calendar shows. Both are optional: without them the calendar keeps its own state.
  3. Handle OnVisibleRangeChanged to load the events of the visible range. It fires after the first render and whenever navigation or a view switch changes the range.
  4. Set AriaLabel to name the calendar for screen readers.

Event kinds #

The Month view shows all-day, multi-day, and timed events, each in its own color. An event that crosses a week row continues on the next row. A timed event shows its start time. A day with more events than fit shows +N more; select it to see the whole day. Times are shown exactly as you supply them, with no time-zone conversion.
How to use:
  1. Set Data to your list of events.
  2. Set StartField, EndField, and TitleField to functions that read an event. For an all-day event, set the end to the start of the day after its last day.
  3. Set AllDayField to mark all-day events and ColorField (CalendarColor) to color them.
  4. Handle OnEventClick and OnDayClick to react to clicks, for example by opening your own form in a Modal. The calendar shows no form of its own.
  5. Bind SelectedDate with @bind-SelectedDate to read or set the selected day.

Week, Work week, and Day #

The Week, Work week, and Day views show day columns with an all-day row above an hourly grid. All-day and multi-day events sit in the all-day row. A timed event is placed by its start and end, and events that overlap in time sit side by side.
How to use:
  1. Set or bind View to CalendarView.Week, CalendarView.WorkWeek, or CalendarView.Day, or let the user pick the view in the toolbar.
  2. Set WorkDays to the days the Work week view shows. The default is Monday to Friday.
  3. Handle OnSlotClick to react to a click on an empty time slot, for example by opening your own form with the slot's start and end.
  4. Set AllDayText to change the label of the all-day row.

Time grid settings #

Set the slot length, the visible hours, and the working hours of the Week, Work week, and Day views. Time outside working hours is shaded, and today's column shows a line at the current time on the user's device. The hourly grid scrolls inside a set height and opens an hour before the current time when today is shown, otherwise at the start of the working day.
How to use:
  1. Set SlotMinutes to 15, 30, or 60.
  2. Set DayStart and DayEnd (TimeOnly) to limit the hours the grid shows. Leave both at their default to show the whole day.
  3. Set WorkDayStart, WorkDayEnd, and WorkDays to choose the hours and days that are not shaded.
  4. Set Height to the height of the hourly grid in pixels. Set it to 0 to show the whole grid and let the page scroll.

Drag to select, move, and resize #

Drag across days or time slots to select a range. Drag an event to move it, or drag one of its ends to resize it. In the Week, Work week, and Day views a timed event snaps to the slot length. In the Month view an event moves by whole days and keeps its time of day. Press Escape during a drag to cancel it. On a touch screen, press and hold before dragging; a quick swipe scrolls.
The calendar never changes your data. Each drag raises a callback with the new times, and the event moves only when you update your list, so you can validate or reject a change.
How to use:
  1. Handle OnRangeSelected to react to a selected range, for example by opening your own form to create an event.
  2. Handle OnEventMoved and OnEventResized, and set the event's start and end from NewStart and NewEnd to apply the change. Do nothing to leave the event where it was.
  3. Set AllowRangeSelection, AllowEventMove, or AllowEventResize to false to turn an action off.
  4. Check that the user is allowed to make the change in your own handler; the calendar does not know your rules.

Customizing #

Draw the inside of every event with your own template, mark days with a label, a highlight, or non-working shading, and hide weekdays you do not need. The calendar follows the Bootstrap theme, so it changes with light and dark mode and with your theme's colors.
How to use:
  1. Set EventTemplate to replace the content of every event. Its context carries your item, the title, the start and end, and the view.
  2. Set DayMarkProvider to a function that returns a CalendarDayMark for a day: a Label, a Color that tints the day, and IsNonWorking to shade it. Return null for other days.
  3. Set HiddenDays to the weekdays to leave out, for example Saturday and Sunday. An event that covers a hidden day keeps its part on the days that are shown.

Holidays and week numbers #

Pass a list of holidays and the calendar labels each with its name and shades it as a non-working day in every view. Week numbers show beside each week in the Month view and in the corner of the Week, Work week, and Day views.
How to use:
  1. Set Holidays to a list of CalendarHoliday items, each with a date and a name. The calendar holds no holiday data of its own.
  2. Set ShowWeekNumbers to true to show week numbers. When it is false, they are not rendered at all.
  3. Set WeekNumberRule to Culture to number weeks by the culture's rule, or to Iso8601. The two differ around the new year: in January 2027 with the en-US culture, the week of 3 January is week 2 by the culture's rule and week 1 by ISO 8601.
  4. Set WeekNumberText to change the short heading of the week numbers.

Agenda #

The Agenda view lists the events of a period, grouped by day. Days without events are left out. All-day events come first, then timed events by start time. An event that covers several days appears on each of them.
How to use:
  1. Set or bind View to CalendarView.Agenda, or let the user pick it in the toolbar.
  2. Set AgendaDays to the number of days the list covers. The default is 7. Previous and next move by that many days.
  3. Set EmptyText to the text shown for a period without events.

Compact layout #

Below a breakpoint the calendar shows a compact layout for small screens. The view switch becomes a list. The Month view shows a marker on each day that has events and lists the selected day's events below the grid. The Week and Work week views keep readable day columns and scroll sideways inside the calendar, so the page itself never scrolls sideways.
How to use:
  1. Set CompactBreakpoint (CalendarCompactBreakpoint) to the width below which the compact layout shows. The default is Medium (768px).
  2. Set it to None to keep the full layout at every width.
  3. Bind SelectedDate to choose the day whose events the compact Month view lists.

Changing events #

The calendar reads your list each time it renders, so adding, changing, or removing an event shows at once. A null or empty list shows an empty calendar.
How to use:
  1. Keep your events in a list and pass it to Data.
  2. Add, change, or remove items in your own code, for example in a button handler or after saving a form.
  3. No refresh call is needed when the change happens in an event handler of the component that holds the list.

Localization #

Month and day names, date and time formats, the 12 or 24 hour clock, and the first day of the week follow the calendar's culture. By default that is the app's current culture. You can show one calendar in another culture, and override the first day of the week and the time format without changing the culture.
How to use:
  1. Set Culture to a CultureInfo to show one calendar in another culture. Leave it unset to follow the app.
  2. Set FirstDayOfWeek to start weeks on another day, and TimeFormat (CalendarTimeFormat) to force a 12-hour or 24-hour clock.
  3. Translate the built-in text with the text parameters: TodayText, PreviousText, NextText, ViewText, MonthText, WeekText, WorkWeekText, DayText, AgendaText, AllDayText, MoreTextFormat, EmptyText, WeekNumberText, and CloseText. Each has an English default.
  4. Set AriaLabel in the same language to name the calendar for screen readers.

Calendar systems #

With a culture whose calendar is not Gregorian, such as Persian (fa-IR) or Umm al-Qura (ar-SA), the title, the month grid, the day numbers, the agenda, and the jump-to-date picker follow that calendar. Your events keep their ordinary DateTime values, and each one still sits on its actual day.
How to use:
  1. Set Culture to a culture that uses the calendar you need, or run your app in that culture.
  2. In a Blazor WebAssembly app, add <BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData> to the project file. Without it the browser loads only part of the culture data, and these cultures may not be available.
INFO
The month names and date formats come from .NET's culture data, which is not the same on a server and in the browser. In Blazor WebAssembly, the month names of these calendars can appear in English (for example Aban), and the title can include the era. The days, months, and years shown are the same in both.

Right to left #

In a right-to-left page the calendar is mirrored: the days run from right to left, the toolbar and the time column swap sides, and dragging follows the mirrored layout. The calendar's own styles use start and end instead of left and right, so no extra setting is needed.
How to use:
  1. Set dir="rtl" on the page (usually on the html element) or on an element around the calendar.
  2. For a whole right-to-left page, load Bootstrap's right-to-left stylesheet (bootstrap.rtl.min.css) so Bootstrap's own parts, such as button groups, are mirrored too.
  3. Set Culture and the text parameters for the language, as in the Localization section.

Keyboard #

Every view works without a mouse, except moving and resizing an event by dragging. To change an event's times from the keyboard, open your own form from OnEventClick. Days, time slots, and events carry their full date, time, and title as their accessible name, so a screen reader announces them.
How to use:
  1. Press Tab to reach the toolbar, one day or time slot of the grid, and each event.
  2. On a day or a time slot, press the arrow keys to move, Home and End to go to the ends of the week or the day, and Page Up and Page Down to show the previous or next period.
  3. Press Enter or Space to activate a day, a time slot, or an event. This raises OnDayClick, OnSlotClick, or OnEventClick, the same as a click.
  4. Press Esc to close the jump-to-date picker or a day's event list. Focus returns to the button that opened it.
  5. Set AriaLabel to name the calendar for screen readers.

Create and edit with a form #

The calendar has no editor of its own. Open your own form, for example a Modal with an EditForm, from the calendar's callbacks, and change your list when the form is saved. A Grid bound to the same list shows the same events.
How to use:
  1. Handle OnEventClick to open the form with the event, and OnSlotClick and OnRangeSelected to open it with the chosen start and end.
  2. On save, add or change the item in the list bound to Data. The calendar shows the change on its next render.
  3. Handle OnEventMoved and OnEventResized to apply a drag, after any check your app needs. This is also the place to reject a change the user is not allowed to make.
  4. A Grid keeps its own copy of the rows, so call its RefreshDataAsync method after each change.

Inside a modal, an offcanvas, and tabs #

A calendar can sit inside a Modal, an Offcanvas, or a Tab. When it is rendered while hidden, it takes its size and scrolls to its opening time when it is first shown.
How to use:
  1. Put the Calendar in the BodyTemplate of a Modal or an Offcanvas, or in the Content of a Tab.
  2. Use a large modal (ModalSize.ExtraLarge) for the Month and Week views.
  3. The compact layout follows the width of the screen, not of the container. In a narrow container, such as an offcanvas, choose the Day or Agenda view.

Changing settings at runtime #

Every setting is an ordinary parameter. Change the value it is bound to at any time and the calendar renders again with it: the view, the date, the culture, the time grid, holidays, hidden days, and the drag switches.
How to use:
  1. Bind each parameter to a field or property of your page.
  2. Change the field in an event handler. No method call on the calendar is needed.
  3. Use @bind-View and @bind-Date when the user and your code both change the view or the date.

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.