Documentation / Forms
Calendar
The inline calendar: it picks a date and hands it back, with no field or popover around it. Three modes share the same grid: single (one date), multiple (a list, capped by max) and range (a period { from, to }). Each mode is controlled (value + onChange) or not (defaultValue), and so can the displayed month be (month + onMonthChange).
A full ARIA grid from the keyboard (arrows, Page Up / Down to change month, Home / End). Month and day names follow locale through Intl.DateTimeFormat, but the week starts on Sunday by default: for a French audience, pass locale="fr-FR" and weekStartsOn={1}. The button labels follow UILabelsProvider (calendar… keys), and the labels prop overrides them for one instance.
Client component ("use client"). To schedule tasks over time, use GanttChart; for a dashboard period, ChartPeriodPicker.
Examples
One date
The default single mode; onChange returns the chosen Date, or null.
import { useState } from "react";
import { Calendar, type CalendarLabels } from "@synertech/ui";
const frLabels: CalendarLabels = {
previousMonth: "Mois précédent",
nextMonth: "Mois suivant",
today: "Aujourd’hui",
clear: "Effacer",
monthSelect: "Mois",
yearSelect: "Année",
weekNumber: "Semaine",
};
export function Basic() {
const [date, setDate] = useState<Date | null>(new Date());
return (
<div className="flex flex-col gap-3">
<Calendar
locale="fr-FR"
weekStartsOn={1}
labels={frLabels}
value={date}
onChange={setDate}
bordered
/>
<p className="text-sm text-gray-600 dark:text-gray-300">
Date choisie : {date ? date.toLocaleDateString("fr-FR") : "aucune"}
</p>
</div>
);
}A period
mode="range" selects a start then an end; numberOfMonths shows two months side by side.
import { useState } from "react";
import { Calendar, type CalendarDateRange, type CalendarLabels } from "@synertech/ui";
const frLabels: CalendarLabels = {
previousMonth: "Mois précédent",
nextMonth: "Mois suivant",
today: "Aujourd’hui",
clear: "Effacer",
monthSelect: "Mois",
yearSelect: "Année",
weekNumber: "Semaine",
};
export function Range() {
const [stay, setStay] = useState<CalendarDateRange>({ from: null, to: null });
return (
<Calendar
mode="range"
locale="fr-FR"
weekStartsOn={1}
labels={frLabels}
numberOfMonths={2}
minDate={new Date()}
value={stay}
onChange={setStay}
clearButton
bordered
/>
);
}Several dates
mode="multiple" holds a list of dates; max limits how many.
import { useState } from "react";
import { Calendar, type CalendarLabels } from "@synertech/ui";
const frLabels: CalendarLabels = {
previousMonth: "Mois précédent",
nextMonth: "Mois suivant",
today: "Aujourd’hui",
clear: "Effacer",
monthSelect: "Mois",
yearSelect: "Année",
weekNumber: "Semaine",
};
export function Multiple() {
const [days, setDays] = useState<Date[]>([]);
return (
<Calendar
mode="multiple"
locale="fr-FR"
weekStartsOn={1}
labels={frLabels}
max={3}
value={days}
onChange={setDays}
color="success"
footer={
<p className="text-xs text-gray-500">{days.length} / 3 jours de télétravail choisis</p>
}
/>
);
}Unavailable dates
minDate / maxDate bound the choice; disabledDates accepts a list or a predicate.
import { Calendar, type CalendarLabels } from "@synertech/ui";
const frLabels: CalendarLabels = {
previousMonth: "Mois précédent",
nextMonth: "Mois suivant",
today: "Aujourd’hui",
clear: "Effacer",
monthSelect: "Mois",
yearSelect: "Année",
weekNumber: "Semaine",
};
export function Disabled() {
const today = new Date();
const inTwoMonths = new Date(today.getFullYear(), today.getMonth() + 2, today.getDate());
const isWeekend = (date: Date) => date.getDay() === 0 || date.getDay() === 6;
return (
<Calendar
locale="fr-FR"
weekStartsOn={1}
labels={frLabels}
minDate={today}
maxDate={inTwoMonths}
disabledDates={isWeekend}
todayButton
bordered
/>
);
}Custom cells
renderDay receives the date and its state (selected, today, disabled…) to draw the cell.
import { Calendar, type CalendarLabels } from "@synertech/ui";
const frLabels: CalendarLabels = {
previousMonth: "Mois précédent",
nextMonth: "Mois suivant",
today: "Aujourd’hui",
clear: "Effacer",
monthSelect: "Mois",
yearSelect: "Année",
weekNumber: "Semaine",
};
const bookedDays = [3, 8, 14, 22];
export function CustomDays() {
return (
<Calendar
locale="fr-FR"
weekStartsOn={1}
labels={frLabels}
bordered
renderDay={(date, state) => (
<span className="relative flex flex-col items-center">
{date.getDate()}
{!state.outside && bookedDays.includes(date.getDate()) && (
<span
className="absolute -bottom-1 h-1 w-1 rounded-full bg-orange-500"
aria-hidden="true"
/>
)}
</span>
)}
/>
);
}API reference
Components
import { Calendar } from "@synertech/ui";Props — CalendarProps
| Prop | Type | Default | Description |
|---|---|---|---|
bordered |
boolean |
true |
Wrap the calendar in a bordered, rounded surface. |
captionLayout |
"label" | "dropdown" |
"label" |
Caption as plain text or as month/year dropdowns. |
clearButton |
boolean |
false |
Show a "Clear" shortcut in the footer. |
color |
CalendarColor |
"primary" |
|
defaultMonth |
Date |
— | Uncontrolled initial displayed month. |
defaultValue |
Date | null | Date[] | CalendarDateRange |
— | |
disabled |
boolean |
false |
Disable the whole calendar. |
disabledDates |
Date[] | ((date: Date) => boolean) |
— | Extra non-selectable dates, as a list or a predicate. |
fixedWeeks |
boolean |
false |
Always render 6 week rows so the height never shifts. |
footer |
ReactNode |
— | Extra footer content, rendered below the grid. |
fromYear |
number |
— | First year offered by the year dropdown. |
labels |
CalendarLabels |
— | Accessible labels for the navigation and footer controls. |
locale |
string |
— | BCP 47 tag the month and weekday names are written in. Defaults to the |
max |
number |
— | Maximum number of selectable dates. |
maxDate |
Date |
— | Latest selectable date (inclusive). |
minDate |
Date |
— | Earliest selectable date (inclusive). |
mode |
"single" | "multiple" | "range" |
"single" |
|
month |
Date |
— | Controlled displayed month (any date within it). |
numberOfMonths |
number |
1 |
Number of consecutive months rendered side by side. |
onChange |
((date: Date | null) => void) | ((dates: Date[]) => void) | ((range: CalendarDateRange) => void) |
— | |
onMonthChange |
(month: Date) => void |
— | Called with the first day of the new displayed month. |
renderDay |
(date: Date, state: CalendarDayState) => ReactNode |
— | Override the content of a day cell. |
showOutsideDays |
boolean |
true |
Render the leading/trailing days of the adjacent months. |
showWeekNumbers |
boolean |
false |
Render an ISO week-number column. |
size |
CalendarSize |
"md" |
|
today |
Date |
— | The day marked as today, and the one the "Today" shortcut goes to. Defaults to the clock, read when the calendar mounts. A server and a browser in another time zone do not read the same day there: an application that renders on the server passes it. |
todayButton |
boolean |
false |
Show a "Today" shortcut in the footer. |
toYear |
number |
— | Last year offered by the year dropdown. |
value |
Date | null | Date[] | CalendarDateRange |
— | |
weekStartsOn |
CalendarWeekStart |
0 |
First day of the week — 0 = Sunday … 6 = Saturday. |
+ 276 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).
Types
CalendarDateRange
Interfaceinterface CalendarDateRange| Field | Type | Default | Description |
|---|---|---|---|
from• |
Date | null |
— | |
to• |
Date | null |
— |
CalendarDayState
InterfaceVisual/semantic state of a day cell, handed to renderDay.
interface CalendarDayState| Field | Type | Default | Description |
|---|---|---|---|
disabled• |
boolean |
— | |
inRange• |
boolean |
— | |
outside• |
boolean |
— | |
rangeEnd• |
boolean |
— | |
rangeStart• |
boolean |
— | |
selected• |
boolean |
— | |
today• |
boolean |
— |
CalendarLabels
Interfaceinterface CalendarLabels| Field | Type | Default | Description |
|---|---|---|---|
clear |
string |
— | |
monthSelect |
string |
— | |
nextMonth |
string |
— | |
previousMonth |
string |
— | |
today |
string |
— | |
weekNumber |
string |
— | |
yearSelect |
string |
— |
CalendarColor
Typetype CalendarColor = "primary" | "success" | "warning" | "error" | "info" | "neutral"CalendarMode
Typetype CalendarMode = "single" | "multiple" | "range"CalendarSize
Typetype CalendarSize = "sm" | "md" | "lg"type CalendarWeekStart = 0 | 1 | 2 | 3 | 4 | 5 | 6