0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Next.js】schedule-xの導入方法

Last updated at Posted at 2026-01-17

必要なパッケージのインストール

まず、必要なパッケージをインストールします。

npm install @schedule-x/react @schedule-x/calendar @schedule-x/theme-default @schedule-x/events-service temporal-polyfill

カレンダーコンポーネントの作成

Next.jsではクライアントコンポーネントとして実装する必要があります。

'use client'

import { useNextCalendarApp, ScheduleXCalendar } from '@schedule-x/react'
import {
  createViewDay,
  createViewWeek,
  createViewMonthGrid,
  createViewMonthAgenda,
} from '@schedule-x/calendar'
import { createEventsServicePlugin } from '@schedule-x/events-service'
import { useState } from 'react'
import 'temporal-polyfill/global'
import '@schedule-x/theme-default/dist/index.css'

export default function CalendarApp() {
  const eventsService = useState(() => createEventsServicePlugin())[0]

  const calendar = useNextCalendarApp({
    views: [
      createViewDay(),
      createViewWeek(),
      createViewMonthGrid(),
      createViewMonthAgenda()
    ],
    events: [
      {
        id: '1',
        title: 'サンプルイベント',
        start: Temporal.PlainDate.from('2025-01-20'),
        end: Temporal.PlainDate.from('2025-01-20'),
      },
    ],
    plugins: [eventsService],
    callbacks: {
      onRender: () => {
        eventsService.getAll()
      }
    }
  })

  return (
    <div>
      <ScheduleXCalendar calendarApp={calendar} />
    </div>
  )
}

スタイルの調整

カレンダーのサイズを調整するため、CSSを追加します。

.sx-react-calendar-wrapper {
  width: 1200px;
  max-width: 100vw;
  height: 800px;
  max-height: 90vh;
}

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?