Docs
Calendar
Plugins
⭐ Sidebar

Sidebar

A component for adding a sidebar to the calendar. Enables you to toggle the visibility of calendars, adds a button for opening the interactive event modal, and enables you to create events through dragging and dropping placeholder events.

This is a premium plugin which requires an active license to be used. Learn more at Schedule-X premium.

Features & demo

  • Toggle visibility of calendars
  • Open interactive event modal
  • Drag to create events

Go to Demo


2. Installation

2.1 Set up premium auth (only once)

Follow the instructions for setting up an .npmrc

2.2 Install

npm install @sx-premium/sidebar

Usage

import { createCalendar } from '@schedule-x/calendar'
import { createSidebarPlugin, translations as sidebarTranslations } from "@sx-premium/sidebar";
import { createEventsServicePlugin } from "@schedule-x/events-service";
import { createInteractiveEventModal, translations as modalTranslations } from "@sx-premium/interactive-event-modal";
import { createDragToCreatePlugin } from "@sx-premium/drag-to-create";
import { translations, mergeLocales } from '@schedule-x/translations'
 
import '@sx-premium/sidebar/index.css'
import '@sx-premium/interactive-event-modal/index.css'
import '@schedule-x/theme-default/dist/time-picker.css'
 
const eventsService = createEventsServicePlugin()
const interactiveEventModal = createInteractiveEventModal({
  eventsService,
  availablePeople: ['John Doe', 'Jane Doe'],
  onAddEvent: (event) => {
    console.log('Event added', event)
  }
})
const sidebar = createSidebarPlugin({
  eventsService,
 
  // Optional: Should the sidebar be open on render
  openOnRender: false,
 
  // Optional: Which calendars should be active on render
  activeCalendarIds: ['personal', 'work', 'leisure', 'school'],
 
  // Optional: Should there be calendar toggles
  hasCalendarToggles: true,
 
  // Optional: placeholder events for drag-to-create
  placeholderEvents: [
    {
      title: 'Morning brief',
      calendarId: 'internal',
      people: ['John Doe', 'Jane Doe', 'Steve Smith'],
    },
    {
      title: 'Client demo',
      calendarId: 'internal',
      people: ['John Doe', 'Jane Doe'],
    },
    {
      title: 'Team meeting',
      calendarId: 'clients',
      people: ['John Doe', 'Jane Doe', 'Steve Smith'],
    }
  ],
 
  // Optional: factory function for generating event ids when events are created
  idFactory: () => uuidv4() // or any other id generator
})
 
const calendar = createCalendar(
  {
    translations: mergeLocales(
      translations,
      sidebarTranslations,
      modalTranslations
    )
    // ...config options
  },
  [
    eventsService,
    sidebar,
    interactiveEventModal,
    createDragToCreatePlugin(/* drag-to-create options */)
  ]
)
 
calendar.render(document.getElementById('your-calendar-wrapper'))
 

Changelog

See changelog page.

Examples

These can be added on request. Please let us know if you need an example for a specific framework.

Last updated on

We use cookies for marketing purposes. By clicking "Accept", you consent to the use of all cookies. If you decline, we will only use functional cookies. You can read more about our cookie policy here.