A composable calendar component with day, week, and month views for displaying and managing events with drag interactions.
import {Agenda, useAgenda} from "@heroui-pro/react";
const agenda = useAgenda({events, defaultView: "week"});
<Agenda {...agenda}>
<Agenda.Header>
<Agenda.Heading />
<Agenda.ViewSelector />
<Agenda.Navigation>
<Agenda.NavButton slot="previous" />
<Agenda.TodayButton />
<Agenda.NavButton slot="next" />
</Agenda.Navigation>
</Agenda.Header>
<Agenda.Body>
{/* Day and Week views */}
<Agenda.WeekHeader />
<Agenda.AllDaySection>
<Agenda.AllDayLabel>all-day</Agenda.AllDayLabel>
<Agenda.AllDayEvent event={event} colStart={0} colSpan={1} row={0} />
</Agenda.AllDaySection>
<Agenda.TimeGrid>
<Agenda.CurrentTimeIndicator />
<Agenda.DayColumns>
<Agenda.DayColumn date={day}>
<Agenda.Event event={event} />
</Agenda.DayColumn>
</Agenda.DayColumns>
</Agenda.TimeGrid>
{/* Month view */}
<Agenda.MonthGrid>
<Agenda.MonthRow spanningRowCount={rowCount}>
<Agenda.MonthSpanningEvent event={event} colStart={0} colSpan={1} row={0} />
<Agenda.MonthCell date={day}>
<Agenda.MonthEvent event={event} />
</Agenda.MonthCell>
</Agenda.MonthRow>
</Agenda.MonthGrid>
</Agenda.Body>
</Agenda>;The Agenda supports three views controlled via the ViewSelector or programmatically through setView:
In Day and Week views, render one Agenda.DayColumn per entry of agenda.renderedDays inside Agenda.DayColumns, and one Agenda.Event per entry of agenda.getEventsForDay(day). Place agenda.allDayLayout items in Agenda.AllDaySection with their event, colStart, colSpan, and row. In Month view, render one Agenda.MonthRow per week of agenda.visibleWeeks, using getMonthRowLayout(week) for its spanning events and getPerCellEvents(day, week) for each cell's events.
Set allowsSwipe to slide through the days with a horizontal swipe in Day and Week views, on a trackpad or with a finger. The days follow the swipe and snap to the nearest day when it ends, so a week can start on any day. A trackpad's momentum carries them further, and so does a flick: it goes on to the next day at least. The previous, next, and Today buttons slide to their new days too.
const agenda = useAgenda({events, allowsSwipe: true});
<Agenda.TimeGrid>
<Agenda.CurrentTimeIndicator />
<Agenda.DayColumns>
{agenda.renderedDays.map((day) => (
<Agenda.DayColumn key={day.toString()} date={day}>
{/* events */}
</Agenda.DayColumn>
))}
</Agenda.DayColumns>
</Agenda.TimeGrid>The swipe draws days past each side of the screen: a week on each side in Week view and three days in Day view. Render renderedDays instead of visibleDays in Agenda.DayColumns. Agenda.WeekHeader and Agenda.AllDaySection handle this on their own. visibleDays stays the days on screen, which suits range labels and data fetching. Vertical scrolling still moves the hours, and the days stay put while an event is dragged, resized, or created. A finger swipe starts on the days, not the hour labels. The days' tracks set touch-action: pan-y pinch-zoom, so sideways finger moves go to the swipe while the browser keeps scrolling the hours and zooming the page.
const agenda = useAgenda({
events,
timeZone: "America/New_York",
firstDayOfWeek: "mon",
hourCycle: 24,
});timeZone sets today, the current time indicator, past events, and event time labels. It defaults to the local time zone. Event times are wall-clock times in this zone.firstDayOfWeek starts Week and Month views on a given day ("sun" to "sat") instead of the locale's.hourCycle shows hour labels and event times on a 12- or 24-hour clock instead of the locale's.Events are defined as an array of AgendaEvent objects:
interface AgendaEvent {
id: string;
title: string;
start: CalendarDateTime;
end: CalendarDateTime;
color?: string;
isAllDay?: boolean;
isReadOnly?: boolean;
status?: "confirmed" | "unconfirmed" | "declined";
}status: "unconfirmed" to render an event with a dashed border on the Agenda's background, indicating a tentative or pending event.status: "declined" to keep an event on the calendar with an outline, muted text, and a struck-through title.isReadOnly: true to prevent an event from being moved or resized. The event can still be selected but drag interactions are disabled and the resize handle is hidden.data-past and fade toward --agenda-surface, unless selected. Set --agenda-past-fade to change how far they fade, or to 0% to turn it off.--agenda-event-gap short of its end, so one that starts as another ends doesn't touch it. Events shorter than snapMinutes, including zero-length ones, are laid out for the time they're drawn, beside any event that starts with them.--agenda-surface, so hour lines, weekend shading, and other events never show through them. It defaults to var(--color-background); set it to the color behind the Agenda when that differs, such as a card's.data-short and show their title and start time on one line. Narrow events, such as overlapping ones, hide their time.Drag interactions are enabled when you pass their callbacks:
On mobile, drag interactions (create, move, resize) are disabled by default. Pass undefined for the drag callbacks on small screens to control this.
Snapping and callbacks. Creating, moving, and resizing snap to snapMinutes (default 5). A drag to create snaps its start down and its end up. A click creates an event of defaultEventDuration minutes (default 60) in the slot it lands in.
const agenda = useAgenda({
events,
snapMinutes: 15,
defaultEventDuration: 30,
onEventCreate: (event) => { /* { start, end } */ },
onEventMove: (id, start, end) => { /* moved */ },
onEventResize: (id, start, end) => { /* resized */ },
onEventDelete: (id) => { /* deleted via Delete/Backspace key */ },
onEventSelect: (id) => { /* selected */ },
});All-day events appear in a collapsible section above the time grid. Multi-day all-day events span across day columns.
The section includes an expand/collapse toggle beside the hour labels. Agenda.AllDayLabel renders inside the toggle, so clicking the label also collapses the section. When collapsed, event counts are shown per day (e.g. "2 events"). Customize the collapsed label with the collapsedLabel prop on Agenda.AllDaySection, and the toggle's accessible name with expandLabel and collapseLabel.
All-day events are packed into rows earliest first, then longest first.
getMonthRowLayout(week) to compute layout positions and getPerCellEvents(day, week) for per-cell events.Agenda.MonthCell limits visible events via the maxEvents prop (default: 2). Overflow shows a "N more" link that navigates to the day view. Customize the label with the moreLabel prop.Saturday and Sunday columns automatically receive a subtle gray background (data-weekend attribute) in all views.
A live indicator shows the current time in the time grid:
HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.
The Agenda component uses these CSS classes:
.agenda: Root container. Sets CSS custom properties for sizing..agenda--day / .agenda--week / .agenda--month: Active view, from view.agenda__create-preview: Dashed preview rectangle during drag-to-create..agenda__drop-preview: Outlined preview at the target position during drag-to-move..agenda__header: Flex container for heading, view selector, and navigation..agenda__heading: Month/year title text..agenda__navigation: Wrapper for nav buttons and today button..agenda__nav-button: Override hook for navigation arrow buttons (uses HeroUI Button)..agenda__today-button: Override hook for the Today button (uses HeroUI Button)..agenda__view-selector: Override hook for the view selector (uses HeroUI Segment)..agenda__body: Wrapper around the active view's grid.agenda__body--month: Body layout in month view.agenda__week-header: Row of day headers above the time grid..agenda__day-header: Individual day header with name and date..agenda__day-header-name / .agenda__day-header-date: Weekday name and date number in a day header.agenda__all-day-section: Row of all-day events..agenda__all-day-gutter: Holds the toggle beside the hour labels..agenda__all-day-grid: Grid of all-day events, one column per rendered day..agenda__all-day-toggle: Expand/collapse button with the chevron and label..agenda__all-day-label: "all-day" label text..agenda__all-day-event: All-day event bar..agenda__all-day-summary: Collapsed event count per day..agenda__all-day-dividers / .agenda__all-day-divider: Column dividers behind all-day events.agenda__time-grid: Scrollable time grid container..agenda__time-grid--day / .agenda__time-grid--week: Time grid layout for day and week views.agenda__time-labels: Sticky column of hour labels..agenda__time-label: Individual hour label..agenda__days: Clips a row (day headers, all-day events, current time) to the days on screen..agenda__days-track: Holds a row's rendered days. With allowsSwipe, it is wider than the screen, moves with the swipe, and sets touch-action: pan-y pinch-zoom..agenda__current-time-indicator: Row marking the current time.agenda__current-time-label-wrap / .agenda__current-time-label: Current time label in the hour column.agenda__current-time-track: Holds the current time line across the day columns.agenda__current-time-line--faded / .agenda__current-time-line--active: Faint line across visible days, and the solid segment over today.agenda__day-columns: Clips the day columns to the days on screen..agenda__day-column: Column for a single day's events..agenda__time-slot: Individual hour slot row..agenda__event: Positioned event card in the time grid..agenda__event-title: Event title text..agenda__event-time: Event time range text..agenda__resize-handle: Bottom resize handle with hover indicator..agenda__month-grid: Month grid container..agenda__month-weekday-header: Sticky weekday names row..agenda__month-weekday: Single weekday name in the weekday header.agenda__month-row: Week row in the month grid..agenda__month-cell: Individual day cell..agenda__month-cell-date: Date number button (navigates to day view)..agenda__month-cell-more: "N more" overflow link..agenda__month-event: Per-cell event in month view..agenda__month-spanning-event: Multi-day event bar spanning across cells.[data-dragging]: Applied during drag interactions.[data-resizing]: Applied during resize.[data-selected="true"]: Applied to selected events.[data-status="unconfirmed"]: Dashed border style for tentative events.[data-status="declined"]: Outlined, struck-through style for declined events.[data-past]: Applied to events that have ended.[data-short]: Applied to timed events too short for two lines.[data-readonly]: Applied to read-only events.[data-weekend]: Applied to weekend columns and cells.[data-today]: Applied to today's date elements.[data-drop-target]: Applied to the target cell during drag.--agenda-slot-height: Height of each hour slot (default: 60px).--agenda-time-column-width: Width of the time labels column (default: 58px).--agenda-current-time-color: Color of the current time indicator (default: var(--color-danger)).--agenda-event-radius: Border radius of event cards (default: var(--radius-md)).--agenda-event-gap: Space left under each timed event, so back-to-back events don't touch (default: 2px).--agenda-event-foreground: Text color of all-day and multi-day month events without a color. Events with a color use white (default: var(--color-accent-foreground)).--agenda-surface: The color behind the Agenda, which event fills and the past fade are mixed onto (default: var(--color-background)).--agenda-past-fade: How far past events fade toward --agenda-surface (default: 40%).Root component. Wraps children in context and Motion providers.
Also supports all HTML div props.
Container for heading, view selector, and navigation controls.
Also supports all HTML div props.
Displays the current month and year (e.g. "May 2026").
Also supports all HTML h1 props.
Segmented control for switching between day, week, and month views. Built on the HeroUI Segment component.
| Prop | Type | Default | Description |
|---|---|---|---|
size | "sm" | "md" | "lg" | "sm" | Size of the segment control. |
Navigation button for previous/next. Built on the HeroUI Button component.
| Prop | Type | Default | Description |
|---|---|---|---|
slot | "previous" | "next" | - | Direction of navigation. |
aria-label | string | "Previous" / "Next" | Accessible name of the button. |
Button to navigate to today's date. Built on the HeroUI Button component.
Collapsible section for all-day events with a CSS grid layout for spanning events.
| Prop | Type | Default | Description |
|---|---|---|---|
collapsedLabel | (count: number) => string | "N events" | Custom label for collapsed event counts. |
expandLabel | string | "Expand all-day events" | Accessible name of the toggle while the section is collapsed. |
collapseLabel | string | "Collapse all-day events" | Accessible name of the toggle while the section is expanded. |
An all-day event bar positioned in the grid.
| Prop | Type | Default | Description |
|---|---|---|---|
event | AgendaEvent | - | The event data. Required. |
colStart | number | - | Grid column start index (0-based). |
colSpan | number | - | Number of columns to span. |
row | number | - | Row index for stacking. |
Clips the time grid's day columns to the days on screen and holds them on the track a swipe slides. Without children, it renders a column with its events for each of renderedDays.
Also supports all HTML div props.
A timed event card positioned absolutely in a day column. Supports drag-to-move and drag-to-resize.
| Prop | Type | Default | Description |
|---|---|---|---|
event | AgendaEvent | - | The event data. Required. |
Also supports HTML div props and ref, such as data-*, aria-*, and onContextMenu.
A day cell in the month grid. Limits visible events and shows overflow.
| Prop | Type | Default | Description |
|---|---|---|---|
date | CalendarDate | - | The date for this cell. Required. |
maxEvents | number | 2 | Maximum number of events to show before overflow. |
moreLabel | (count: number) => string | "N more" | Custom label for the overflow link. |
spanningRowCount | number | 0 | Number of spanning event rows above this cell. |
A multi-day event bar in the month grid, positioned absolutely across cells.
| Prop | Type | Default | Description |
|---|---|---|---|
event | AgendaEvent | - | The event data. Required. |
colStart | number | - | Column start index (0-based). |
colSpan | number | - | Number of columns to span. |
row | number | - | Row index for vertical stacking. |
A per-cell event in the month grid. Supports drag-to-move across cells.
| Prop | Type | Default | Description |
|---|---|---|---|
event | AgendaEvent | - | The event data. Required. |
Also supports HTML div props and ref.
The main hook for managing agenda state. Returns all data and methods needed by the component.
| Option | Type | Default | Description |
|---|---|---|---|
events | AgendaEvent[] | - | Array of events to display. Required. |
defaultView | "day" | "week" | "month" | "week" | Initial view. |
view | "day" | "week" | "month" | - | Controlled view state. |
onViewChange | (view: AgendaView) => void | - | Called when the view changes. |
defaultDate | CalendarDate | today | Initial focused date. |
date | CalendarDate | - | Controlled date state. |
onDateChange | (date: CalendarDate) => void | - | Called when the date changes. |
startHour | number | 0 | First visible hour in the time grid. |
endHour | number | 24 | Last visible hour in the time grid. |
slotDuration | number | 60 | Duration of each time slot in minutes. |
onEventCreate | (event: {start, end}) => void | - | Called when dragging to create a new event. |
onEventDelete | (id: string) => void | - | Called when Delete/Backspace is pressed on a selected event. |
onEventMove | (id, start, end) => void | - | Called when an event is dragged to a new position. |
onEventResize | (id, start, end) => void | - | Called when an event is resized. |
onEventSelect | (id: string | null) => void | - | Called when an event is selected or deselected. |
selectedEventId | string | null | - | Controlled selected event state. |
weekDays | number | 7 | Days in Week view. Fewer than 7 are centered on the date. |
allowsSwipe | boolean | false | Slides through the days with a horizontal trackpad or touch swipe in Day and Week views. |
timeZone | string | local | Time zone for today, the current time, and event times. |
firstDayOfWeek | "sun" | "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | locale | First day of the week in Week and Month views. |
hourCycle | 12 | 24 | locale | Clock for hour labels and event times. |
snapMinutes | number | 5 | Minutes that creating, moving, and resizing snap to. |
defaultEventDuration | number | 60 | Length in minutes of an event created with a click. |
Besides the state above, useAgenda returns visibleDays (the days on screen), renderedDays (visibleDays plus the days drawn past each side for allowsSwipe), and setVisibleStart(day), which moves the days so day is the first one on screen.
| Key | Action |
|---|---|
Enter / Space | On an event: selects it (onEventSelect) |
Delete / Backspace | Deletes the selected event (onEventDelete) |
ArrowUp / ArrowDown | On a timed event: moves it by snapMinutes. On a month event: moves it by a week (onEventMove) |
ArrowLeft / ArrowRight | On a timed event: moves it to the previous or next day in view. On a month event: moves it by a day (onEventMove) |
Shift + ArrowUp / ArrowDown | On a timed event: shortens or extends it by snapMinutes (onEventResize) |
Enter | On the time grid: creates an event of defaultEventDuration on the agenda's date, at the first slot in view (onEventCreate) |
Arrow keys / Page Up / Page Down / Home / End | On the time grid: scrolls it |
events updates.Resources