A composable calendar component with day, week, and month views for displaying and managing events with drag interactions.
Import the Agenda component and the useAgenda hook. Access all subcomponents using dot notation.
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 / Week view */}
<Agenda.WeekHeader />
<Agenda.AllDaySection>
<Agenda.AllDayLabel>all-day</Agenda.AllDayLabel>
{agenda.allDayLayout.map((item) => (
<Agenda.AllDayEvent key={item.event.id} event={item.event} colStart={item.colStart} colSpan={item.colSpan} row={item.row} />
))}
</Agenda.AllDaySection>
<Agenda.TimeGrid>
<Agenda.CurrentTimeIndicator />
<Agenda.DayColumns>
{agenda.renderedDays.map((day) => (
<Agenda.DayColumn key={day.toString()} date={day}>
{agenda.getEventsForDay(day).map((event) => (
<Agenda.Event key={event.id} event={event} />
))}
</Agenda.DayColumn>
))}
</Agenda.DayColumns>
</Agenda.TimeGrid>
{/* Month view */}
<Agenda.MonthGrid>
{agenda.visibleWeeks.map((week, i) => {
const rowLayout = agenda.getMonthRowLayout(week);
return (
<Agenda.MonthRow key={i} spanningRowCount={rowLayout.rowCount}>
{rowLayout.items.map((item) => (
<Agenda.MonthSpanningEvent key={item.event.id} event={item.event} colStart={item.colStart} colSpan={item.colSpan} row={item.row} />
))}
{week.map((day, colIdx) => (
<Agenda.MonthCell key={day.toString()} date={day} spanningRowCount={rowLayout.rowCountPerCol[colIdx] ?? 0}>
{agenda.getPerCellEvents(day, week).map((event) => (
<Agenda.MonthEvent key={event.id} event={event} />
))}
</Agenda.MonthCell>
))}
</Agenda.MonthRow>
);
})}
</Agenda.MonthGrid>
</Agenda.Body>
</Agenda>The Agenda supports three views controlled via the ViewSelector or programmatically through setView:
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";
}Set status: "unconfirmed" to render an event with a dashed border on the Agenda's background, indicating a tentative or pending event.
Set status: "declined" to keep an event on the calendar with an outline, muted text, and a struck-through title.
Events that ended before the current time get 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.
Each timed event stops --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.
Event fills are mixed onto --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.
Events too short for two lines get data-short and show their title and start time on one line. Narrow events, such as overlapping ones, hide their time.
A timed event that ends on a later day is drawn on its start day and stops at midnight.
Set 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.
All drag interactions work out of the box when callbacks are provided:
On mobile, drag interactions (create, move, resize) are disabled by default. The consumer controls this by passing undefined for the drag callbacks when on a small screen.
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});const agenda = useAgenda({
events,
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.
All-day events are packed into rows earliest first, then longest first.
Multi-day all-day events render as bars spanning across the month grid row. Use 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.
Clicking a date number in the month grid navigates to that date in day view. The first day of each month shows the month name (e.g. "May 1").
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:
.agenda — Root container. Sets CSS custom properties for sizing.--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-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%)..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__week-header — Row of day headers above the time grid..agenda__day-header — Individual day header with name and date..agenda__time-grid — Scrollable time grid container..agenda__time-labels — Sticky column of hour labels..agenda__time-label — Individual hour label..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__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__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__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__month-grid — Month grid container..agenda__month-weekday-header — Sticky weekday names row..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__create-preview — Dashed preview rectangle during drag-to-create..agenda__drop-preview — Outlined preview at the target position during drag-to-move.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.
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. |
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. |
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.