-
Notifications
You must be signed in to change notification settings - Fork 0
calendar enhanced
The Calendar component is a flexible, responsive calendar solution that supports multiple views, event display, and color schemes.
<x-calendar />- Multiple views: day, week, month, year
- Event display with color schemes
- Responsive design
- Dark mode support
- Custom color schemes
- Event interaction
| Property | Type | Default | Description |
|---|---|---|---|
| id | string | auto-generated | Unique identifier for the calendar |
| months | int | 1 | Number of months to display (for month view) |
| locale | string | 'en-EN' | Locale for date formatting |
| weekendHighlight | bool | false | Whether to highlight weekends |
| sundayStart | bool | false | Whether to start the week on Sunday (default is Monday) |
| colorScheme | string | 'primary' | Color scheme for the calendar (primary, secondary, accent, custom) |
| customColor | string | null | Custom color for the calendar (hex code, used when colorScheme is 'custom') |
| view | string | 'month' | Calendar view (day, week, month, year) |
| config | array | [] | Additional configuration options |
| events | array | [] | Events to display on the calendar |
The Calendar component supports four different views:
Shows a detailed view of a single day.
<x-calendar view="day" />Shows a week-long period.
<x-calendar view="week" />Shows a full month (default view).
<x-calendar view="month" />Shows a full year.
<x-calendar view="year" />The Calendar component supports four different color schemes:
<x-calendar color-scheme="primary" /><x-calendar color-scheme="secondary" /><x-calendar color-scheme="accent" /><x-calendar color-scheme="custom" custom-color="#8A2BE2" />Events can be displayed on the calendar using the events property. Each event should be an array with the following properties:
| Property | Type | Required | Description |
|---|---|---|---|
| id | string | No | Unique identifier for the event (auto-generated if not provided) |
| date | string | Yes (or range) | Date of the event (YYYY-MM-DD format) |
| range | array | Yes (or date) | Date range of the event ([start_date, end_date]) |
| label | string | No | Short label for the event (displayed on the calendar) |
| title | string | No | Title of the event (displayed in tooltip) |
| start_time | string | No | Start time of the event (displayed in tooltip) |
| colorScheme | string | No | Color scheme for the event (primary, secondary, accent, custom) |
| customColor | string | No | Custom color for the event (hex code, used when colorScheme is 'custom') |
<x-calendar
:events="[
[
'id' => 'meeting-1',
'date' => '2025-07-20',
'label' => 'Team Meeting',
'title' => 'Quarterly planning session',
'start_time' => '10:00',
'colorScheme' => 'primary',
],
[
'id' => 'conference-1',
'range' => ['2025-07-25', '2025-07-27'],
'label' => 'Conference',
'title' => 'Annual industry conference',
'start_time' => '09:00',
'colorScheme' => 'accent',
]
]"
/>The Calendar component dispatches a custom event when an event is clicked. You can listen for this event using Alpine.js:
<div
x-data="{
handleEventClick(eventId) {
// Handle event click
console.log('Event clicked:', eventId);
}
}"
@calendar-event-click.window="handleEventClick($event.detail.eventId)"
>
<x-calendar
:events="[
[
'id' => 'meeting-1',
'date' => '2025-07-20',
'label' => 'Team Meeting',
'title' => 'Quarterly planning session',
'start_time' => '10:00',
'colorScheme' => 'primary',
]
]"
/>
</div>The Calendar component is fully responsive and adapts to different screen sizes:
- Large screens: Full day names, more detailed event information
- Medium screens: Abbreviated day names, compact event display
- Small screens: Minimal day names, simplified event display
The Calendar component supports dark mode out of the box. It uses Tailwind's dark mode variants to apply appropriate styling in dark mode.
The Calendar component provides navigation controls to move between time periods:
- Previous: Navigate to the previous day, week, month, or year (depending on the current view)
- Today: Jump to the current date
- Next: Navigate to the next day, week, month, or year (depending on the current view)
The Calendar component is designed with accessibility in mind:
- Proper color contrast for all color schemes
- Keyboard navigation support
- Screen reader friendly markup
- ARIA attributes for interactive elements
<x-calendar /><x-calendar color-scheme="custom" custom-color="#8A2BE2" /><x-calendar
view="week"
:events="[
[
'date' => '2025-07-20',
'label' => 'Meeting',
'title' => 'Team meeting',
'start_time' => '10:00',
'colorScheme' => 'primary',
]
]"
/><div
x-data="{
handleEventClick(eventId) {
// Handle event click
console.log('Event clicked:', eventId);
}
}"
@calendar-event-click.window="handleEventClick($event.detail.eventId)"
>
<x-calendar
:events="[
[
'id' => 'meeting-1',
'date' => '2025-07-20',
'label' => 'Team Meeting',
'title' => 'Quarterly planning session',
'start_time' => '10:00',
'colorScheme' => 'primary',
]
]"
/>
</div>