Aller au contenu principal

WeeklyCalendar

Every example on this page is live, drawn by the library's Storybook, where you can also change its props and see the result.

A Google Calendar-style weekly view. Displays events across 7 days with configurable hour range and automatic overlap handling.

The text grows with the columns, and each block shows its name, ending in "…" when it is too long, then its time and details when it is tall enough. Events that take whole days sit as bars in a row above the hours, with a "+N more" line when there are more than fit.

Import​

import { WeeklyCalendar } from "~lib/calendar/weekly-calendar";

Props​

NameTypeRequiredDefaultDescription
eventsCalendarEvent[]YesN/AEvents to display
weekStartDateDateYesN/AAny day in the week to display
firstDayOfWeek"sunday" | "monday"No"sunday"Which day starts the week
startHournumberNo8First visible hour
endHournumberNo20Hour the grid ends at
widthnumber | stringNo300Container width
heightnumber | stringNo300Container height
size"auto" | "sm" | "md" | "lg"No"auto"Text size; "auto" grows it with the width of the columns
timeZonestringNoThe device's zoneTime zone to read days and times in, such as "Europe/London"
timeFormat"24h" | "12h"No"24h"Label hours and times on a 24-hour or a 12-hour clock

CalendarEvent​

NameTypeRequiredDescription
namestringYesEvent title
startDateYesStart time
endDateYesEnd time
idstringNoUnique identifier
descriptionstringNoShown below the name when the block is tall enough
allDaybooleanNoTakes whole days; drawn in the row above the hours
participantsPerson[]NoShown below description when the block is tall enough
shadingPatternTypeNoFill pattern (solid, diagonal, dots, crosshatch)

Examples​

Default​

Ouvrir Default dans Storybook

Overlapping Events​

Ouvrir Overlapping Events dans Storybook

Full Week​

Ouvrir Full Week dans Storybook

Custom Hours​

Ouvrir Custom Hours dans Storybook

With Patterns​

Ouvrir With Patterns dans Storybook

With Participants​

Ouvrir With Participants dans Storybook

Small Square​

Ouvrir Small Square dans Storybook

Wide Panel​

Ouvrir Wide Panel dans Storybook

All-Day Events​

Events that take whole days, and timed events of a day or longer, are drawn as bars above the hours. When there are more than the row holds, a day counts the rest.

Ouvrir All Day Events dans Storybook

12-Hour Clock​

Ouvrir Twelve Hour Clock dans Storybook

See Also​