月間カレンダーEventCalendarExperimental
Month calendar with events: a 週×曜日 day-cell grid for a month with events placed as chips on their date (capped per day with a '+N' overflow), today marked, out-of-month days de-emphasised, role=grid semantics (weekday columnheaders, day gridcells with a composed accessible name) and roving-tabindex keyboard nav (arrows ±1 day / ±1 week, Home/End, Enter to select). Owns the month math (pass month + events); today is injectable (SSR-safe). For editorial / content calendars, schedules, bookings and any events-on-dates view.
プレビュー
Props
表は横にスクロールできます
| プロパティ | 型 | 初期値 | 説明 |
|---|---|---|---|
| month | string | Date | - | Any date within the month to show ("YYYY-MM" / "YYYY-MM-DD" / Date). The component computes the 6-week grid. |
| events | CalendarEvent[] | - | { id, date, label, tone?, ariaLabel? }. Placed as chips on their date; multiple per day stack with a +N overflow. |
| today | string | Date | - | The date marked as today. Injectable (pass it in) so render stays SSR-safe — no internal new Date(). |
| weekStartsOn | 0 | 1 | 0 | 0 = Sunday, 1 = Monday. |
| maxPerDay | number | 3 | Max event chips per day before a +N affordance. |
| weekdayLabels | string[] | 日 月 火 … | 7 short weekday labels starting Sunday. |
| renderEvent | (event) => ReactNode | - | Render an event chip (default: a tone pill). |
| onSelectDate | (iso: string) => void | - | Day clicked / Enter on the focused day. |
| onSelectEvent | (event) => void | - | An event chip clicked. |
| onMonthChange | (month: Date) => void | - | When provided, renders a header with the month title + prev/next buttons. |
| label | ReactNode | - | Accessible name for the grid. |
Usage
import * as React from "react"
import { EventCalendar, type CalendarEvent } from "@gunjo/ui"
const events: CalendarEvent[] = [
{ id: "a1", date: "2026-06-03", label: "特集: 夏の旅", tone: "info" },
{ id: "a4", date: "2026-06-15", label: "入稿締切: 連載#12", tone: "destructive" },
{ id: "a8", date: "2026-06-24", label: "公開: 群青UI 解説", tone: "primary" },
]
function Calendar() {
const [month, setMonth] = React.useState(new Date(2026, 5, 1))
return (
<EventCalendar
month={month}
events={events}
today="2026-06-24" // injectable — SSR-safe
onMonthChange={setMonth} // renders prev/next header
onSelectDate={(iso) => openDay(iso)}
onSelectEvent={(e) => openEvent(e)}
/>
)
}