Calendar

Calendar

Data Display
Navigation

Full-featured calendar with month, week, and day views for event management.

Preview

Interactive calendar with multiple view modes

 

Sun
Mon
Tue
Wed
Thu
Fri
Sat

Event Colors

Five semantic color options for categorizing events

defaultStandard events
successCompleted or positive events
warningImportant or pending events
dangerCritical or overdue events
infoInformational events

Props

Component API reference

Calendar

PropTypeDefaultDescription
eventsCalendarEvent[][]Array of events to display
onEventClick(event: CalendarEvent) => void—Callback when event is clicked
classNamestring—Additional CSS classes

CalendarEvent

PropTypeDefaultDescription
id*string—Unique event identifier
title*string—Event title/name
date*Date—Event date and time
color'default' | 'success' | 'warning' | 'danger' | 'info''default'Event color category
hournumber—Hour of day for the event

Usage

Import and implementation examples

import { Calendar, type CalendarEvent } from '@/components/ui/calendar'
import { useState } from 'react'
export default function MyComponent() {
const [selectedEvent, setSelectedEvent] = useState<CalendarEvent | null>(null)
const events: CalendarEvent[] = [
{
id: '1',
title: 'Team Meeting',
date: new Date(2025, 11, 5, 10, 0),
color: 'default',
hour: 10
},
{
id: '2',
title: 'Product Launch',
date: new Date(2025, 11, 10, 14, 0),
color: 'success',
hour: 14
},
]
return (
<Calendar
events={events}
onEventClick={(event) => setSelectedEvent(event)}
/>
)
}

Features

Built-in functionality

  • Three view modes: Month, week, and day views
  • Five event colors: Default, success, warning, danger, info
  • Interactive events: Click handlers for event selection
  • Navigation controls: Previous, next, and today buttons
  • Scrollable views: Scrollable day and week views
  • Responsive design: Adapts to container width

Accessibility

Accessibility considerations

ARIA Attributes

role="grid" for calendar gridaria-label for navigation buttonsaria-selected for current date

Keyboard Navigation

KeyAction
Arrow keysNavigate between dates
EnterSelect date or event
TabNavigate between controls

Notes

  • Screen readers announce date and event information
  • Keyboard navigation through calendar grid
  • Focus indicators on interactive elements