Data display

Full Calendar

An event calendar drawn by FullCalendar 7, with month, week and day views, configured with the library's own options. It loads the library on demand in the app's language, follows the light and dark color scheme and redraws when Livewire sends new options. For picking a date in a form, use the calendar or date picker instead.

Blade

A spinner shows while the library loads, then a month grid with the two events on their days, under a toolbar with the previous and next buttons and the month name in the app's language; FullCalendar 7 shows no toolbar without headerToolbar. options is what FullCalendar takes in new FullCalendar.Calendar(element, options), as a PHP array.

Events from Livewire #

After addReview() the calendar is drawn again with the new event, staying on the week and view the user was looking at.

Events: 1
Blade

Events from a URL #

FullCalendar requests the URL with start and end query parameters for the range on screen, and again when the user moves to another month or week.

Blade

Callbacks written in JavaScript #

data-options is a JavaScript object merged over options, for what a PHP array cannot carry: here clicking an event calls open() with its id, and clicking a day calls create() with the date.

open(): — · create(): —
Blade

Week view and toolbar #

Any FullCalendar option works: here initialView opens the week grid and headerToolbar adds view switches.

Blade

Rendered event #

rendered fires with the FullCalendar instance each time the calendar is drawn.

Showing:
Blade

Locale and palette #

locale sets the language and palette the theme colors.

Blade

Customization #

Classes go to the calendar <div>; loadable: reaches the wrapper around it.

Blade

Reference

tk:full-calendar

Prop Type Default Description
options array null The FullCalendar options: initialView, events, headerToolbar, initialDate...
locale string the app's locale The language of the calendar (pt_BR, en, es...). Its translation file is loaded with the library.
theme string monarch The FullCalendar 7 theme to load.
palette string blue The color palette of the theme.

data-options is an attribute, not a prop: a JavaScript expression that returns an object of options.

Events

Event Detail When
rendered { fullCalendar }, the FullCalendar instance The calendar was drawn: the first time and on each update of the options.
started The library started loading. Not fired with loadable:silent.
completed The library is loaded; the calendar is drawn right after.
failed The library could not be loaded, or FullCalendar threw while drawing.

Prefixes

Prefix Goes to
loadable: The wrapper around the calendar, the spinner and the error. loadable:silent hides the spinner.
loadable:loading: The spinner shown while the library loads.
loadable:error: The error message.

Events

rendered is dispatched on the calendar element, the <div> the tag's attributes go to, and does not bubble: listen on the tag itself. started, completed and failed are dispatched on the wrapper around it and do not bubble either, so they are listened to with the loadable: prefix.

With Alpine:

blade

Calling a Livewire action:

blade

Customization

Classes and attributes on the tag go to the calendar <div>, which is w-full h-full by default. To reach the elements around it, prefix the attribute (listed in the Reference above).

blade

The height follows FullCalendar's height and aspectRatio options.

Accessibility

FullCalendar renders the grid with its own roles and labels, and its toolbar buttons are real buttons with accessible names in the calendar's language. The spinner and the error message are role="status" regions.

Behavior notes

  • The library, the theme and its palette are loaded from https://cdn.jsdelivr.net/npm/fullcalendar@7 by the first calendar on the page. When window.FullCalendar already exists, as when the app bundles it, none of them is requested: theme and palette have no effect and the app loads the theme and its CSS itself. The locale file is still requested from jsDelivr.
  • The locale file is loaded for any locale other than en and en-US. A regional code with no file of its own (pt-xx) falls back to the language (pt); a language with no file leaves the calendar in English.
  • The color scheme follows the dark class of <html>: the wrapper's data-color-scheme switches between light and dark, which the themes use, without redrawing.
  • A Livewire update that changes options updates the same calendar (resetOptions), so the date, the view, the scroll and the focus stay; new events show at once. When an option the previous options had is missing (a weekends the server stopped sending), the calendar is created again at the same date and view, so that option goes back to its default and rendered brings the new instance. getCalendar(), callable from Alpine expressions on the tag, returns the current instance.
  • data-options is merged deeply over options: nested objects are combined key by key ({ headerToolbar: { end: 'today prev,next' } } keeps the PHP headerToolbar.start), while arrays and other values are taken whole from data-options.