enes

Calendar View

The Calendar View is an inline calendar for browsing days, months and years. It supports selecting a single date or several dates, minimum and maximum bounds, blackout dates, and a configurable week start and locale.

Usage

<script>
	import { CalendarView } from 'fluentui-svelte';

	let value = $state(null);
</script>

<CalendarView bind:value onChange={(e, selection) => console.log(selection)} />

Multiple Selection

Set the multiple prop to allow selecting more than one date.

Range Selection

Set selectionMode to range to pick a start and an end. The range has its own binding rather than sharing value, and end stays null between the two clicks, so a half-built range is distinguishable from a range of a single day.

Week Start

Use the weekStart prop to change the first day of the week (0 = Sunday, 3 = Wednesday).

CalendarView Props

NameTypeDefaultDescription
ref bindableHTMLDivElementThe DOM reference of the calendar element.
value bindableDate | Date[] | nullnullThe selected date, or an array of dates when `selectionMode` is `'multiple'`. Unused by `'range'`.
selectionMode'single' | 'multiple' | 'range''single'How many dates the grid hands out, and in what shape.
range bindable{ start: Date | null; end: Date | null; }{ start: null, end: null }The picked range. Only read and written when `selectionMode` is `'range'`, and `end` stays `null` until the range is closed.
blackoutBreaksRangebooleanfalseStop a range from spanning a blacked-out date.
blackoutDatesDate[]Dates that are rendered but cannot be selected.
headersbooleanLabels the first cell of a month or a year with its name.
minDateDateThe earliest selectable date.
maxDateDateThe latest selectable date.
view'days' | 'months' | 'years''days'The calendar page the view opens on.
localestring'en-US'The locale used to format weekday and month names.
weekStartnumber1The first day of the week, where 0 is Sunday.
floatingCalendarViewFloatingRenders the calendar as a popup anchored to a reference element instead of inline.
onChange(event: Event, value: Date | Date[] | null) => voidCalled whenever the selection changes. Not called in `'range'` mode.
onRangeChange(event: Event, range: CalendarDateRange) => voidFired on every step of a range, including the one that leaves `end` null.
onViewChange(event: Event, view: View) => voidCalled whenever the active calendar page changes.
Element Attributes (div)

CalendarViewItem Props

NameTypeDefaultDescription
selectedbooleanRenders the cell as the selected one.
disabledbooleanDisables the user interaction.
currentbooleanMarks the cell as the current date.
outOfRangebooleanRenders the cell as belonging to a neighbouring page.
blackoutbooleanRenders the cell as blacked out, so it reads as unavailable rather than disabled.
rangePosition'start' | 'between' | 'end'Set on the days a range covers, which paints the band behind them.
headerstringA small label rendered above the cell content.
variant'day' | 'monthYear''day'Which shape the cell takes: a circle for a day, a rounded rectangle for a month or a year.
childrenSnippetThe content of the cell.
buttonAttributesHTMLButtonAttributesThe attributes to spread on the inner button element.
Element Attributes (div)