Calendar

The user's real schedule as a week, day or month, coloured by calendar, or what's on today with to-dos, with any changes the agent proposes shown in place before anything is written.

Pattern

≈ 2,640 tokens per use (tool 1,555 · guidance 467 · typical payload 618)How token costs are estimated

Example: Calendar

What does my week look like?

This week, Oct 12–16, 2026. Times in America/New York.

Oct 12–16, 2026

  • Work
  • Team
  • Personal
View

Monday, October 12

Tuesday, October 13

Wednesday, October 14, today

Thursday, October 15

Friday, October 16

When to use

  • The user asks what their day, week or month looks like.
  • The user asks "What's on today?" and wants a glance, not a grid: use view: "today", with the day's to-dos when the agent has them.
  • The agent wants to change their calendar (move, add or cancel events), and the user should see the changes in context before they're written.
  • A plan has times that interact with existing meetings: focus blocks, an offsite agenda, rescheduling.

When not to use

  • The user needs to pick one free time for a new booking. Use the Slot Picker.
  • The agent hasn't read the calendar. Fetch events first; never invent a schedule.
  • The question has a one-line answer, e.g. "When is my next meeting?". Say it in text.

How the agent should use it

  • Every event comes from the calendar connector, with its real id, times and calendar; every to-do from the task connector. Pass the user's calendars too, so events are coloured.
  • Set timezone to the user's zone and give times with offsets.
  • For view: "today", set range.start to that day and pass that day's events and to-dos. For that day as a timeline, use view: "day".
  • Pass the whole range you fetched, including free events, so overlaps and conflicts are accurate.
  • Use proposals for every change, each with a one-line reason. For move and cancel, set eventId to the existing event.
  • Without proposals the calendar is display-only and returns nothing.
  • To show another stretch of time, call it again with a new range and view: week shows up to 7 days at a time (5 for a work week), month the whole month. The look is fixed; asked to restyle it, say so.
  • Write only the accepted proposal IDs from an apply result. On revise or dismiss, write nothing.

Interaction

Week and day (view: "week", "day") are a time grid: the title, then one column per day headed in small mono type ("Mon 12", today in the foreground colour), hours down the left ("9a", "12p") with faint lines across, and no column lines. The hours are workingHours (default 9 to 5), grown to fit every event; past 12 hours they get shorter, so the grid never scrolls inside the card. Events are 8px blocks filled with their calendar's colour; overlapping events share the column side by side, all-day events sit as pills above the hours, and a free event is hollow with a border. range.days sets the width: 5 for a work week, up to 7. Below about 80px a column, the grid scrolls sideways with faded edges.

Month (view: "month") is the month of range.start as rounded day tiles, weeks starting on the locale's first day. Each tile has its date at the top left (today filled; press it to open that day) and its events at the bottom as pills with the title and a compact start time ("10a", "1:30p"). A day with more than three events shows three and +N more under the date, which shows the rest in place.

Today (view: "today") is a list for one day. A mono date line ("Today · Thu, Oct 15") sits opposite the count ("3 events · 2 to-dos"). Each event is a row filled with its calendar's colour: start time (or All day, or Until 9:00 AM for one that began the day before), title and duration ("15 min"); the one running now says Now instead of its duration. To-dos follow as To do rows with a square status mark, checked and struck through when done. The mark isn't a control: completing tasks belongs to the To-do List. On a narrow card the title moves under the time so it is never cut to a few letters.

Colours. Calendars are told apart by colour and by a small shape (in the legend, the details card and on events with room), so colour is never the only cue. An event is a solid block in its calendar's colour with its own text colour: slate blue, teal, gold and green for the first four calendars (after Google Calendar's dark theme, with deeper fills in light mode), and grey for any later calendar and for events with no calendar. Text is at least 4.5:1 on its fill in both themes. A free event is hollow with a border and shows its calendar's colour in the marker. Pass calendars for the legend order and calendar on each event.

Details. Pressing an event (or Enter or Space on it) opens a small card above it, centred on the event and kept inside the screen; it fades and scales in and out (instantly with reduced motion). It shows the time, calendar, location, attendee count and an Open link when url is a safe http(s) link; for a proposal it also says where the event was or goes, and why. Focus moves into the card; the close button, Esc, a click elsewhere or a second press on the event closes it and returns focus to the event. Only one card is open at a time, and it never opens on hover: pressing a different event while a card is open slides the card to that event. Existing events can't be edited here.

Views and navigation. A Week / Day / Month switch sits in the header when the events can fill more than one: Day is always offered, Week when they cover more than one day, Month when they cover 14 days or more (or it is the first view). Previous, next and Today move between periods, and are enabled only when the provided events reach them; otherwise they say why ("Nothing earlier", "Nothing later"). Navigation is local view state; it never fetches. Today (the list) has no switch or navigation.

Proposals. A proposed change is the solid block in the foreground colour (white in dark mode, black in light) with its title and start time, so it stands out from the colours. A move leaves an empty dashed outline where the event was; a cancel is dashed and struck through. Below the calendar, each change is written out ("Move Investor call · Thu 3:00 PM to Fri 3:00 PM · Dana Park is free Friday afternoon") with any conflict under it ("Conflicts with Team lunch"). With more than one, each row has a checkbox, all included by default; leaving one out removes it from the calendar and rechecks conflicts. Apply sends the decision back, Dismiss closes it, and the message icon asks for a different plan; the component never writes to the calendar itself. After applying, the changes stay in the foreground colour, so the user sees what moved.

Text. No all-caps labels (a user rule, D72): day, hour, time and duration labels are in sentence case ("Mon 12", "9a", "15 min").

Accessibility. Events are buttons in chronological order with full labels, e.g. "Investor call, 3:00 PM to 4:00 PM, Work calendar, proposed, conflicts with Team lunch". Each day in the week grid has a hidden heading ("Thursday, October 15, today"), and the title carries the time zone for screen readers. View and range changes are announced. The sideways-scrolling grids are named regions reachable by keyboard.

Time zones. Days are bucketed in timezone with Intl only, so a week that crosses a daylight-saving change keeps its days and wall-clock times. All-day events use calendar dates with an exclusive end, and count as busy only when busy is true.

Installation

npx shadcn@latest add https://your-site.com/r/calendar.json

Usage

app/api/chat/route.ts
import { tool } from "ai"
import { calendarTool } from "@/components/genui/calendar.schema"

const tools = {
  // With proposals, the call is completed by the user's decision in the UI.
  // Without proposals, give it an execute() that returns immediately.
  [calendarTool.name]: tool({
    description: calendarTool.description,
    inputSchema: calendarTool.inputSchema,
  }),
}
components/message.tsx
import { Calendar } from "@/components/genui/calendar"

function ToolPart({ part, addToolResult }) {
  if (part.type !== "tool-show_calendar") return null

  return (
    <Calendar
      {...part.input}
      status={part.state === "input-streaming" ? "streaming" : undefined}
      result={part.state === "output-available" ? part.output : undefined}
      onResult={(result) =>
        addToolResult({
          tool: "show_calendar",
          toolCallId: part.toolCallId,
          output: result,
        })
      }
    />
  )
}

When there are proposals, the agent receives one of:

{ action: "apply", accepted: ["move-dana", "focus-mon"], declined: ["focus-wed"] }
{ action: "revise", feedback: "Keep Wednesday mornings free" }
{ action: "dismiss" }

calendar-utils.ts exports the pure helpers, so the agent's backend can reuse them: applyProposals(events, proposals, accepted) returns the resulting event list, and findConflicts(events, proposals, timezone, accepted) returns the busy events each proposal overlaps.

With LangGraph

Push it from a graph node with ui.push({ name: "show_calendar", props: { toolCallId, ...args } }, { message }), and render the thread's UI messages with the Renderer.

Restoring from history

When a conversation is reloaded, pass the stored result back as result. After apply, accepted proposals are drawn in the foreground colour at their new times, cancelled and declined ones are gone, and each change is marked accepted or declined. After revise or dismiss, the proposals stay visible with the outcome in the footer. It never calls onResult again, so a decision can't be made twice.

<Calendar
  {...part.input}
  result={part.state === "output-available" ? part.output : undefined}
/>

Schema

PropTypeNotes
titlestring?Defaults to the range label
timezonestringIANA zone, e.g. America/New_York
view"week" | "day" | "month" | "today"The first view. Default week. today is the one-day list
range{ start, days? }start is YYYY-MM-DD (for month, any day in it). days (1 to 42) is how many days the events cover; defaults to 7, 1 (day, today) or the rest of the month. A week of 5 shows a work week
eventsCalendarEvent[]Data-bound. Up to 300
calendars{ id, label }[]Data-bound. Legend order, up to 6. Each gets its own colour
todos{ id, title, done? }[]Data-bound. today only, up to 20
proposalsCalendarProposal[]Up to 20. Omit for a display-only calendar
workingHours{ start, end }HH:mm. Default 09:00–17:00
nowstring?ISO time that counts as now. Omit in real use

CalendarEvent (all data-bound)

FieldTypeNotes
idstringProposals refer to it
titlestring
start, endstringISO with offset; YYYY-MM-DD for all-day (end exclusive)
allDayboolean?
calendarstring?A calendar id or name. Sets the colour
locationstring?Shown in the details card
attendeesnumber?Count
busyboolean?Default true for timed events, false for all-day
urlstring?http(s) only; shown as Open

CalendarProposal

FieldTypeNotes
idstringReturned in the result
kind"create" | "move" | "cancel"
eventIdstring?Required for move and cancel
titlestring
start, endstringThe new time for move; the current time for cancel
reasonstring?One line. Shown in the list of changes and the details card

Host props: status (streaming, ready, submitting, applied, revised, dismissed), onResult, result and className.

Source

On this page