Command palette

@yasinsensoy/web

Web · Components

Calendar

Month calendar.

19 exports

Live example

Preview

SunMonTueWedThuFriSat

Code

import { Calendar } from "@yasinsensoy/web";

<Calendar
  marks={etkinlikGunleri} // ["2026-10-14", …]
  value={gun} onValueChange={setGun} // "2026-10-28" />

Events

  1. Events appear here when you interact with the preview.

Two months side by side, range and week numbers

WkSunMonTueWedThuFriSat
45
46
47
48
49
WkSunMonTueWedThuFriSat
49
50
51
52
53

Import

import {
  Calendar,
  MonthCalendar,
  YearCalendar,
  toISODate,
  parseISODate,
  parseDateRange,
  parseISOMonth,
} from "@yasinsensoy/web";

Calendar

componentClient component

Month calendar. Selects a single day, a date range or several days; used on its own (e.g. on a booking page) or inside DatePicker and DateRangePicker.

  • Language: month and day names and the first day of the week come from UIProvider's locale via Intl (default tr-TR: starts on Monday).
  • Navigation: clicking the month name in the header opens the month view, then the year view; distant dates are three clicks away. On touch screens, swiping left/right changes the month. Month transitions use a short slide animation (off with the reduced motion preference).
  • Limits: days are disabled with min, max and isDateDisabled; in a range the length is limited with minDays/maxDays.
  • Keyboard: ←/→ day, ↑/↓ week, Home/End start/end of week, PageUp/ PageDown month (year with Shift), Enter/Space selects. The calendar is a single tab stop (WAI-ARIA grid).
  • Range: the first click is the start, the second the end; the range is previewed while hovering in between.
  • Today is shown with a ring and days in marks with a dot below.

Values are ISO strings in "YYYY-MM-DD" format; no time zone shift.

Calendar(props: CalendarProps): JSX.Element

Examples

<Calendar defaultValue="2026-10-28" onValueChange={(day) => setDay(day)} />

<Calendar mode="range" months={2} min={new Date()} maxDays={14}
  value={range} onValueChange={setRange} />

<Calendar mode="multiple" marks={eventDays}
  isDateDisabled={(d) => d.getDay() === 0} />

MonthCalendar

componentClient component

Month calendar: shows the 12 months of a year in a grid and lets the user pick one. For selections that don't need a day, such as a billing period, a card expiry date or a monthly report. As a dropdown: MonthPicker.

  • Clicking the year in the header opens the year grid; distant years are two clicks away. The ‹ › buttons change the year.
  • Months are disabled with min, max and isMonthDisabled.
  • Keyboard: arrows move between cells, Enter/Space selects.
  • Month names come from UIProvider locale via Intl.
MonthCalendar(props: MonthCalendarProps): JSX.Element

Examples

<MonthCalendar value={month} onValueChange={setMonth} max={new Date()} />

YearCalendar

componentClient component

Year calendar: picks a year in pages of 12 years (model year, graduation year, annual report). As a dropdown: YearPicker.

  • The ‹ › buttons go 12 years forward/back; arrows navigate on the keyboard.
  • Years are disabled with min, max and isYearDisabled.
YearCalendar(props: YearCalendarProps): JSX.Element

Examples

<YearCalendar defaultValue={2026} min={2000} max={2030} onValueChange={(_, year) => setYear(year)} />

toISODate

function

Turns a Date into an ISO date string in "YYYY-MM-DD" form (the day in local time). Values of the date components and FormData use this form.

toISODate(date: Date): string

Examples

toISODate(new Date(2026, 9, 28)) // "2026-10-28"

parseISODate

function

Turns a "YYYY-MM-DD" (or "YYYY-MM-DDTHH:mm") string into a Date in local time; undefined when invalid. To read the value a DatePicker submits in a server action.

parseISODate(value: string | null | undefined): Date | undefined

Examples

const date = parseISODate(String(data.get("date"))); // Date | undefined
parseISODate("2026-10-28T14:30") // October 28, 2026 14:30

Splits the "start/end" (ISO 8601 interval) value a DateRangePicker submits. When the format is broken, the ends are empty strings.

parseDateRange(value: unknown): DateRange

Examples

parseDateRange(data.get("date")) // { start: "2026-10-01", end: "2026-10-07" }

Turns the "YYYY-MM" value a MonthPicker submits into the first day of the month (local time); undefined when invalid.

parseISOMonth(value: string | null | undefined): Date | undefined

Examples

parseISOMonth("2026-10") // October 1, 2026

Classes that can be given to the inner parts of Calendar.

NameTypeDescription
month?stringContainer of each month.
caption?stringMonth header (previous/next buttons and month name).
grid?stringGrid of days.
day?stringEach day button.

Props shared by all selection modes of the calendar.

NameTypeDefaultDescription
min?DateInputEarliest selectable day. Earlier days are faded and unselectable; previous months can't be reached.
max?DateInputLatest selectable day.
isDateDisabled?(date: Date) => booleanFunction for days that can't be selected (e.g. weekends, booked days). Called for every visible day; keep it fast.
disabled?booleanThe whole calendar is disabled.
readOnly?booleanNavigable, but the selection can't be changed.
month?DateInputVisible (first) month in controlled use; any day of the month can be given. onMonthChange (CalendarBaseProps.onMonthChange) is called when it changes.
defaultMonth?DateInputFirst visible month in uncontrolled use. Defaults to the selected day or today.
onMonthChange?(month: string) => voidCalled with the first day of the month ("2026-10-01") when the visible month changes.
months?number1Number of months shown side by side (usually 2 for range selection).
weekStartsOn?0 | 1 | 2 | 3 | 4 | 5 | 6First day of the week: 0 Sunday, 1 Monday … 6 Saturday. Chosen by locale when omitted (Monday for tr-TR, Sunday for en-US).
showWeekNumbers?booleanfalseShow ISO week numbers at the start of rows?
showOutsideDays?booleantrue` for one month, `false` for multiple monthsShow days outside the month (belonging to the previous/next month) faded? Clicking one moves to that month.
fixedWeeks?booleantrueAlways 6 rows per month? The height doesn't change between months.
marks?readonly DateInput[] | ((date: Date) => boolean)Days that show a small dot below (e.g. events, appointments). A list of days or a function called for each day.
autoFocus?booleanOn open, focus goes to the selected day (otherwise today).
id?stringId of the container.
aria-label?string"Takvim"` (`messages.calendar`)Screen reader name.
aria-labelledby?stringId of the element naming the calendar.
className?stringClasses added to the container.
classNames?CalendarClassNamesClasses added to the inner parts.

Calendar selecting a single day.

NameTypeDefaultDescription
mode?"single""single"Selection mode: "single" one day, "range" a range, "multiple" several days.
value?DateInputSelected day in controlled use; "" for none.
defaultValue?DateInputDay selected initially in uncontrolled use.
onValueChange?(value: string, date: Date | undefined) => voidCalled with the ISO day ("2026-10-28") and a Date when the selection changes.
min?DateInputEarliest selectable day. Earlier days are faded and unselectable; previous months can't be reached.
max?DateInputLatest selectable day.
isDateDisabled?(date: Date) => booleanFunction for days that can't be selected (e.g. weekends, booked days). Called for every visible day; keep it fast.
disabled?booleanThe whole calendar is disabled.
readOnly?booleanNavigable, but the selection can't be changed.
month?DateInputVisible (first) month in controlled use; any day of the month can be given. onMonthChange (CalendarBaseProps.onMonthChange) is called when it changes.
defaultMonth?DateInputFirst visible month in uncontrolled use. Defaults to the selected day or today.
onMonthChange?(month: string) => voidCalled with the first day of the month ("2026-10-01") when the visible month changes.
months?number1Number of months shown side by side (usually 2 for range selection).
weekStartsOn?0 | 1 | 2 | 3 | 4 | 5 | 6First day of the week: 0 Sunday, 1 Monday … 6 Saturday. Chosen by locale when omitted (Monday for tr-TR, Sunday for en-US).
showWeekNumbers?booleanfalseShow ISO week numbers at the start of rows?
showOutsideDays?booleantrue` for one month, `false` for multiple monthsShow days outside the month (belonging to the previous/next month) faded? Clicking one moves to that month.
fixedWeeks?booleantrueAlways 6 rows per month? The height doesn't change between months.
marks?readonly DateInput[] | ((date: Date) => boolean)Days that show a small dot below (e.g. events, appointments). A list of days or a function called for each day.
autoFocus?booleanOn open, focus goes to the selected day (otherwise today).
id?stringId of the container.
aria-label?string"Takvim"` (`messages.calendar`)Screen reader name.
aria-labelledby?stringId of the element naming the calendar.
className?stringClasses added to the container.
classNames?CalendarClassNamesClasses added to the inner parts.

Calendar selecting a date range.

NameTypeDefaultDescription
mode"range"The first click selects the start, the second the end.
value?DateRangeInputSelected range in controlled use.
defaultValue?DateRangeInputInitial range in uncontrolled use.
onValueChange?(range: DateRange) => voidCalled when the selection changes; end is empty until the end is selected.
minDays?numberMinimum number of days in the range (both ends included).
maxDays?numberMaximum number of days in the range (both ends included); far days are disabled once the start is selected.
min?DateInputEarliest selectable day. Earlier days are faded and unselectable; previous months can't be reached.
max?DateInputLatest selectable day.
isDateDisabled?(date: Date) => booleanFunction for days that can't be selected (e.g. weekends, booked days). Called for every visible day; keep it fast.
disabled?booleanThe whole calendar is disabled.
readOnly?booleanNavigable, but the selection can't be changed.
month?DateInputVisible (first) month in controlled use; any day of the month can be given. onMonthChange (CalendarBaseProps.onMonthChange) is called when it changes.
defaultMonth?DateInputFirst visible month in uncontrolled use. Defaults to the selected day or today.
onMonthChange?(month: string) => voidCalled with the first day of the month ("2026-10-01") when the visible month changes.
months?number1Number of months shown side by side (usually 2 for range selection).
weekStartsOn?0 | 1 | 2 | 3 | 4 | 5 | 6First day of the week: 0 Sunday, 1 Monday … 6 Saturday. Chosen by locale when omitted (Monday for tr-TR, Sunday for en-US).
showWeekNumbers?booleanfalseShow ISO week numbers at the start of rows?
showOutsideDays?booleantrue` for one month, `false` for multiple monthsShow days outside the month (belonging to the previous/next month) faded? Clicking one moves to that month.
fixedWeeks?booleantrueAlways 6 rows per month? The height doesn't change between months.
marks?readonly DateInput[] | ((date: Date) => boolean)Days that show a small dot below (e.g. events, appointments). A list of days or a function called for each day.
autoFocus?booleanOn open, focus goes to the selected day (otherwise today).
id?stringId of the container.
aria-label?string"Takvim"` (`messages.calendar`)Screen reader name.
aria-labelledby?stringId of the element naming the calendar.
className?stringClasses added to the container.
classNames?CalendarClassNamesClasses added to the inner parts.

Calendar selecting multiple days.

NameTypeDefaultDescription
mode"multiple"Each click selects or deselects a day.
value?readonly DateInput[]Selected days in controlled use.
defaultValue?readonly DateInput[]Days selected initially in uncontrolled use.
onValueChange?(values: string[], dates: Date[]) => voidCalled with sorted ISO days and Dates when the selection changes.
min?DateInputEarliest selectable day. Earlier days are faded and unselectable; previous months can't be reached.
max?DateInputLatest selectable day.
isDateDisabled?(date: Date) => booleanFunction for days that can't be selected (e.g. weekends, booked days). Called for every visible day; keep it fast.
disabled?booleanThe whole calendar is disabled.
readOnly?booleanNavigable, but the selection can't be changed.
month?DateInputVisible (first) month in controlled use; any day of the month can be given. onMonthChange (CalendarBaseProps.onMonthChange) is called when it changes.
defaultMonth?DateInputFirst visible month in uncontrolled use. Defaults to the selected day or today.
onMonthChange?(month: string) => voidCalled with the first day of the month ("2026-10-01") when the visible month changes.
months?number1Number of months shown side by side (usually 2 for range selection).
weekStartsOn?0 | 1 | 2 | 3 | 4 | 5 | 6First day of the week: 0 Sunday, 1 Monday … 6 Saturday. Chosen by locale when omitted (Monday for tr-TR, Sunday for en-US).
showWeekNumbers?booleanfalseShow ISO week numbers at the start of rows?
showOutsideDays?booleantrue` for one month, `false` for multiple monthsShow days outside the month (belonging to the previous/next month) faded? Clicking one moves to that month.
fixedWeeks?booleantrueAlways 6 rows per month? The height doesn't change between months.
marks?readonly DateInput[] | ((date: Date) => boolean)Days that show a small dot below (e.g. events, appointments). A list of days or a function called for each day.
autoFocus?booleanOn open, focus goes to the selected day (otherwise today).
id?stringId of the container.
aria-label?string"Takvim"` (`messages.calendar`)Screen reader name.
aria-labelledby?stringId of the element naming the calendar.
className?stringClasses added to the container.
classNames?CalendarClassNamesClasses added to the inner parts.

Props of the Calendar component.

type CalendarProps = SingleCalendarProps | RangeCalendarProps | MultipleCalendarProps
NameTypeDefaultDescription
mode?"single" | "range" | "multiple""single"Selection mode: "single" one day, "range" a range, "multiple" several days.
value?DateInput | DateRangeInput | readonly DateInput[]Selected day in controlled use; "" for none.
defaultValue?DateInput | DateRangeInput | readonly DateInput[]Day selected initially in uncontrolled use.
onValueChange?(value: string, date: Date | undefined) => void | (range: DateRange) => void | (values: string[], dates: Date[]) => voidCalled with the ISO day ("2026-10-28") and a Date when the selection changes.
min?DateInputEarliest selectable day. Earlier days are faded and unselectable; previous months can't be reached.
max?DateInputLatest selectable day.
isDateDisabled?(date: Date) => booleanFunction for days that can't be selected (e.g. weekends, booked days). Called for every visible day; keep it fast.
disabled?booleanThe whole calendar is disabled.
readOnly?booleanNavigable, but the selection can't be changed.
month?DateInputVisible (first) month in controlled use; any day of the month can be given. onMonthChange (CalendarBaseProps.onMonthChange) is called when it changes.
defaultMonth?DateInputFirst visible month in uncontrolled use. Defaults to the selected day or today.
onMonthChange?(month: string) => voidCalled with the first day of the month ("2026-10-01") when the visible month changes.
months?number1Number of months shown side by side (usually 2 for range selection).
weekStartsOn?0 | 1 | 2 | 3 | 4 | 5 | 6First day of the week: 0 Sunday, 1 Monday … 6 Saturday. Chosen by locale when omitted (Monday for tr-TR, Sunday for en-US).
showWeekNumbers?booleanfalseShow ISO week numbers at the start of rows?
showOutsideDays?booleantrue` for one month, `false` for multiple monthsShow days outside the month (belonging to the previous/next month) faded? Clicking one moves to that month.
fixedWeeks?booleantrueAlways 6 rows per month? The height doesn't change between months.
marks?readonly DateInput[] | ((date: Date) => boolean)Days that show a small dot below (e.g. events, appointments). A list of days or a function called for each day.
autoFocus?booleanOn open, focus goes to the selected day (otherwise today).
id?stringId of the container.
aria-label?string"Takvim"` (`messages.calendar`)Screen reader name.
aria-labelledby?stringId of the element naming the calendar.
className?stringClasses added to the container.
classNames?CalendarClassNamesClasses added to the inner parts.
minDays?numberMinimum number of days in the range (both ends included).(RangeCalendarProps)
maxDays?numberMaximum number of days in the range (both ends included); far days are disabled once the start is selected.(RangeCalendarProps)

Type of props that take a date: an ISO date string like "2026-10-28" or a Date. For a Date, the day in local time is used.

type DateInput = string | Date

DateRange

interface

A date range. Values are ISO date strings in "YYYY-MM-DD" form; an unselected end is an empty string ("").

NameTypeDescription
startstringStart day.
endstringEnd day (the start is included).

Type of props that take a range; ends may be strings or Dates.

NameTypeDescription
start?DateInput | nullStart day.
end?DateInput | nullEnd day.

Forms accepted by YearPicker and YearCalendar values: 2026, "2026" or Date.

type YearInput = number | string | Date

Props of the MonthCalendar component.

NameTypeDefaultDescription
value?DateInputSelected month in controlled use: "2026-10", any day of the month ("2026-10-28") or a Date; "" for none.
defaultValue?DateInputMonth selected initially in uncontrolled use.
onValueChange?(value: string, date: Date | undefined) => voidCalled with "YYYY-MM" and the first day of the month (Date) when the selection changes.
min?DateInputEarliest selectable month ("2026-01" or a date).
max?DateInputLatest selectable month.
isMonthDisabled?(date: Date) => booleanFunction for months that can't be selected; called with the first day of the month (e.g. closed accounting periods).
monthFormat?"short" | "long" | "numeric""short"Format of month names: "short" ("Oct"), "long" ("October") or "numeric" ("10").
defaultYear?numberFirst visible year in uncontrolled use. Defaults to the selected month or this year.
onYearChange?(year: number) => voidCalled when the visible year changes.
disabled?booleanEntirely disabled.
readOnly?booleanNavigable, but the selection can't be changed.
autoFocus?booleanOn open, focus goes to the selected cell (otherwise this month/year).
id?stringId of the container.
aria-label?string"Takvim"` (`messages.calendar`)Screen reader name.
aria-labelledby?stringId of the element naming the calendar.
className?stringClasses added to the container.

Props of the YearCalendar component.

NameTypeDefaultDescription
value?YearInputSelected year in controlled use: 2026, "2026" or a Date; "" for none.
defaultValue?YearInputYear selected initially in uncontrolled use.
onValueChange?(value: string, year: number | undefined) => voidCalled with the "YYYY" string and the year number when the selection changes ("", undefined when cleared).
min?YearInputEarliest selectable year.
max?YearInputLatest selectable year.
isYearDisabled?(year: number) => booleanFunction for years that can't be selected.
disabled?booleanEntirely disabled.
readOnly?booleanNavigable, but the selection can't be changed.
autoFocus?booleanOn open, focus goes to the selected cell (otherwise this month/year).
id?stringId of the container.
aria-label?string"Takvim"` (`messages.calendar`)Screen reader name.
aria-labelledby?stringId of the element naming the calendar.
className?stringClasses added to the container.