AI meeting scheduler
In-chat meeting slot picker comparing dual calendar availability strips across three openings, booking confirmation, and note entry.
pnpm dlx shadcn@latest add @haze/ai-schedule---
import { Check, FileText, Globe, RotateCcw } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
interface BusyBlock {
start: number;
end: number;
}
interface ScheduleSlot {
id: string;
dayShort: string;
dayLabel: string;
month?: string;
dayNum?: string;
context?: string;
timeRange: string;
startHour: number;
durationHours: number;
yourBusy: BusyBlock[];
guestBusy: BusyBlock[];
}
interface Props {
id?: string;
heading?: string;
userPrompt?: string;
assistantReply?: string;
meetingMeta?: string;
durationLabel?: string;
timezoneLabel?: string;
attendee?: string;
attendeeShort?: string;
slots?: ScheduleSlot[];
class?: string;
}
const {
id = "haze-ai-schedule",
heading = "In-chat meeting scheduler",
userPrompt = "Find 30 minutes with Priya next week for the roadmap",
assistantReply = "You're both free at these times. Pick one and I'll send the invite.",
durationLabel = "30 min",
timezoneLabel = "Your time · CET",
attendee = "Priya Nair",
attendeeShort = "Priya",
slots = [
{
id: "tue",
dayShort: "Tue",
dayLabel: "Tue Nov 11",
month: "NOV",
dayNum: "11",
context: "Before her 11:00",
timeRange: "10:00 – 10:30",
startHour: 10,
durationHours: 0.5,
yourBusy: [
{ start: 8.5, end: 9.5 },
{ start: 13, end: 14.5 },
],
guestBusy: [
{ start: 9, end: 10 },
{ start: 11, end: 12 },
{ start: 15, end: 16 },
],
},
{
id: "wed",
dayShort: "Wed",
dayLabel: "Wed Nov 12",
month: "NOV",
dayNum: "12",
context: "Open for both",
timeRange: "14:30 – 15:00",
startHour: 14.5,
durationHours: 0.5,
yourBusy: [
{ start: 9.5, end: 11 },
{ start: 12, end: 13.5 },
{ start: 15.5, end: 16.5 },
],
guestBusy: [
{ start: 9, end: 10.5 },
{ start: 11.5, end: 13 },
{ start: 15.5, end: 17 },
],
},
{
id: "thu",
dayShort: "Thu",
dayLabel: "Thu Nov 13",
month: "NOV",
dayNum: "13",
context: "End of day for both",
timeRange: "16:00 – 16:30",
startHour: 16,
durationHours: 0.5,
yourBusy: [
{ start: 9, end: 11 },
{ start: 12.5, end: 15 },
],
guestBusy: [
{ start: 10, end: 12 },
{ start: 13, end: 15.5 },
],
},
],
class: className,
} = Astro.props;
const dayStart = 8;
const daySpan = 9.5;
const toPct = (hour: number) => `${Math.max(0, Math.min(100, ((hour - dayStart) / daySpan) * 100)).toFixed(2)}%`;
const toWidth = (hours: number) => `${Math.max(1.5, (hours / daySpan) * 100).toFixed(2)}%`;
const firstSlot = slots[0];
const parseMonth = (slot: ScheduleSlot) => slot.month ?? (slot.dayLabel.split(" ")[1]?.toUpperCase() || "NOV");
const parseDayNum = (slot: ScheduleSlot) => slot.dayNum ?? (slot.dayLabel.split(" ")[2] || "11");
const parseContext = (slot: ScheduleSlot) => slot.context ?? "Open for both";
---
<section
aria-labelledby={`${id}-title`}
data-haze-ai-schedule
data-attendee={attendee}
class={cn("bg-background px-4 py-10 sm:px-6 sm:py-14", className)}
>
<h2 id={`${id}-title`} class="sr-only">{heading}</h2>
<div class="mx-auto max-w-md space-y-3.5">
<div class="flex justify-end">
<p class="max-w-[85%] rounded-2xl bg-muted px-4 py-2.5 text-sm/5 text-foreground">
{userPrompt}
</p>
</div>
<p class="text-[0.9375rem]/6 text-pretty text-foreground">
{assistantReply}
</p>
<div data-sch-picker class="overflow-hidden rounded-2xl border border-border bg-muted/40 p-1.5">
<div class="flex flex-wrap items-center justify-between gap-2 px-3 py-2 text-xs/5">
<h3 id={`${id}-group-label`} class="truncate text-muted-foreground">
<span class="font-semibold text-foreground">{durationLabel}</span> with {attendee}
</h3>
<span class="inline-flex shrink-0 items-center gap-1.5 text-muted-foreground">
<Globe class="size-3.5" aria-hidden="true" />
{timezoneLabel}
</span>
</div>
<div class="rounded-xl border border-border bg-card p-2">
<div
role="radiogroup"
aria-labelledby={`${id}-group-label`}
data-sch-radiogroup
class="space-y-1.5"
>
{
slots.map((slot, index) => {
const selected = index === 0;
return (
<button
type="button"
role="radio"
aria-checked={selected ? "true" : "false"}
tabindex={selected ? 0 : -1}
data-sch-slot={slot.id}
data-day-short={slot.dayShort}
data-day-label={slot.dayLabel}
data-time-range={slot.timeRange}
class="group block w-full cursor-pointer rounded-xl border border-transparent p-2.5 text-left transition-colors duration-150 ease-snappy hover:bg-muted/40 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring aria-checked:border-border aria-checked:bg-muted/40"
>
<div class="flex items-center gap-3">
<span
aria-hidden="true"
class="w-11 shrink-0 overflow-hidden rounded-lg border border-border bg-card text-center"
>
<span class="block bg-muted py-0.5 text-[0.625rem]/3 font-semibold tracking-wide text-muted-foreground uppercase transition-colors duration-150 group-aria-checked:bg-primary group-aria-checked:text-primary-foreground">
{parseMonth(slot)}
</span>
<span class="block py-1 text-sm/4 font-bold text-foreground tabular-nums">
{parseDayNum(slot)}
</span>
</span>
<span class="min-w-0 flex-1">
<span class="block text-sm/5 font-semibold text-foreground tabular-nums">
{slot.dayShort} · {slot.timeRange}
</span>
<span class="mt-0.5 block truncate text-xs/5 text-muted-foreground">
{parseContext(slot)}
</span>
</span>
<span
aria-hidden="true"
class="inline-flex size-5 shrink-0 items-center justify-center rounded-full border border-border-strong bg-field transition-colors duration-150 group-aria-checked:border-primary group-aria-checked:bg-primary"
>
<span class="size-2 rounded-full bg-primary-foreground opacity-0 transition-opacity duration-150 group-aria-checked:opacity-100"></span>
</span>
</div>
<div data-sch-tracks hidden={!selected} aria-hidden="true" class="mt-3 sm:pl-14">
<div class="flex items-stretch gap-3">
<div class="flex w-10 shrink-0 flex-col justify-between py-0.5 text-[0.6875rem]/4 text-muted-foreground">
<span class="truncate">You</span>
<span class="truncate">{attendeeShort}</span>
</div>
<div class="relative flex-1 py-1">
<div class="space-y-3">
<div class="relative h-1.5 w-full rounded-full bg-muted/60">
{
slot.yourBusy.map((block) => (
<span
class="absolute inset-y-0 rounded-full bg-border-strong"
style={`left: ${toPct(block.start)}; width: ${toWidth(block.end - block.start)}`}
></span>
))
}
</div>
<div class="relative h-1.5 w-full rounded-full bg-muted/60">
{
slot.guestBusy.map((block) => (
<span
class="absolute inset-y-0 rounded-full bg-border-strong"
style={`left: ${toPct(block.start)}; width: ${toWidth(block.end - block.start)}`}
></span>
))
}
</div>
</div>
<span
class="pointer-events-none absolute inset-y-0 rounded-sm bg-primary"
style={`left: ${toPct(slot.startHour)}; width: max(${toWidth(slot.durationHours)}, 10px)`}
></span>
</div>
</div>
<div class="mt-1.5 flex items-center gap-3">
<span class="w-10 shrink-0"></span>
<div class="relative h-4 flex-1 text-[0.6875rem]/4 text-muted-foreground tabular-nums">
<span class="absolute -translate-x-1/2" style={`left: ${toPct(9)}`}>9:00</span>
<span class="absolute -translate-x-1/2" style={`left: ${toPct(12)}`}>12:00</span>
<span class="absolute -translate-x-1/2" style={`left: ${toPct(15)}`}>15:00</span>
</div>
</div>
</div>
</button>
);
})
}
</div>
</div>
<div class="flex flex-wrap items-center justify-between gap-3 px-3 pt-2.5 pb-1.5">
<div class="flex flex-wrap items-center gap-3 text-xs/4 text-muted-foreground" aria-hidden="true">
<span class="inline-flex items-center gap-1.5">
<span class="inline-block h-1 w-3 rounded-full bg-border-strong"></span>
Busy
</span>
<span class="inline-flex items-center gap-1.5">
<span class="inline-block h-1 w-3 rounded-full bg-primary"></span>
Free for both
</span>
</div>
<button
type="button"
data-sch-book
class="inline-flex h-9 shrink-0 cursor-pointer items-center rounded-full bg-primary px-5 text-sm/5 font-semibold text-primary-foreground transition-[opacity,scale] duration-150 ease-snappy hover:opacity-92 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring active:scale-[0.97]"
>
<span data-sch-book-label>Book {firstSlot?.dayShort ?? "slot"}</span>
</button>
</div>
</div>
<div
data-sch-confirmed
hidden
class="rounded-2xl border border-frame-success bg-success/8 p-4 animate-rise"
>
<div class="flex flex-wrap items-start justify-between gap-3">
<div class="flex min-w-0 items-start gap-2.5">
<span class="mt-0.5 inline-flex size-6 shrink-0 items-center justify-center rounded-full bg-success/14 text-success" aria-hidden="true">
<Check class="size-3.5" />
</span>
<div class="min-w-0">
<p data-sch-confirmed-title class="text-sm/5 font-semibold text-foreground tabular-nums">
Booked · {firstSlot?.dayLabel}, {firstSlot?.timeRange} CET
</p>
<p class="mt-0.5 text-xs/5 text-muted-foreground">
Calendar invite sent to {attendee}
</p>
</div>
</div>
<div class="flex flex-wrap items-center gap-1.5">
<button
type="button"
data-sch-note-toggle
aria-expanded="false"
aria-controls={`${id}-note-form`}
class="inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-full border border-frame bg-field px-3 text-xs/5 font-medium text-foreground transition-colors duration-150 ease-snappy hover:border-frame-strong hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring active:scale-[0.97]"
>
<FileText class="size-3" aria-hidden="true" />
Add note
</button>
<button
type="button"
data-sch-reset
class="inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-full border border-frame bg-field px-3 text-xs/5 font-medium text-foreground transition-colors duration-150 ease-snappy hover:border-frame-strong hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring active:scale-[0.97]"
>
<RotateCcw class="size-3" aria-hidden="true" />
Reschedule
</button>
</div>
</div>
<p data-sch-saved-note hidden class="mt-3 rounded-xl border border-border bg-card px-3 py-2 text-xs/5 text-foreground"></p>
<form id={`${id}-note-form`} data-sch-note-form hidden class="mt-3 flex flex-wrap items-center gap-2 border-t border-border pt-3">
<label for={`${id}-note-input`} class="sr-only">Agenda note for invite</label>
<input
id={`${id}-note-input`}
type="text"
data-sch-note-input
placeholder="Add agenda or doc link…"
class="min-h-8 min-w-0 flex-1 rounded-full border border-frame-input bg-field px-3 py-1 text-xs/5 text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/24 focus-visible:outline-hidden"
/>
<button
type="submit"
class="inline-flex h-8 cursor-pointer items-center rounded-full bg-primary px-3.5 text-xs/5 font-semibold text-primary-foreground transition-[opacity,scale] duration-150 ease-snappy hover:opacity-92 focus-visible:outline-2 focus-visible:outline-ring active:scale-[0.97]"
>
Save
</button>
</form>
</div>
<p data-sch-status role="status" class="sr-only"></p>
</div>
</section>
<script>
function initAiSchedules() {
document.querySelectorAll<HTMLElement>("[data-haze-ai-schedule]").forEach((root) => {
if (root.hasAttribute("data-enhanced")) return;
root.setAttribute("data-enhanced", "");
const attendee = root.dataset.attendee ?? "attendee";
const picker = root.querySelector<HTMLElement>("[data-sch-picker]");
const confirmed = root.querySelector<HTMLElement>("[data-sch-confirmed]");
const confirmedTitle = root.querySelector<HTMLElement>("[data-sch-confirmed-title]");
const radios = Array.from(root.querySelectorAll<HTMLButtonElement>("[data-sch-slot]"));
const bookBtn = root.querySelector<HTMLButtonElement>("[data-sch-book]");
const bookLabel = root.querySelector<HTMLElement>("[data-sch-book-label]");
const resetBtn = root.querySelector<HTMLButtonElement>("[data-sch-reset]");
const noteToggle = root.querySelector<HTMLButtonElement>("[data-sch-note-toggle]");
const noteForm = root.querySelector<HTMLFormElement>("[data-sch-note-form]");
const noteInput = root.querySelector<HTMLInputElement>("[data-sch-note-input]");
const savedNote = root.querySelector<HTMLElement>("[data-sch-saved-note]");
const status = root.querySelector<HTMLElement>("[data-sch-status]");
let selectedIndex = 0;
const selectSlot = (index: number, moveFocus = false, announce = false) => {
if (!radios.length) return;
selectedIndex = (index + radios.length) % radios.length;
radios.forEach((btn, i) => {
const active = i === selectedIndex;
btn.setAttribute("aria-checked", active ? "true" : "false");
btn.tabIndex = active ? 0 : -1;
const tracks = btn.querySelector<HTMLElement>("[data-sch-tracks]");
if (tracks) tracks.hidden = !active;
});
const current = radios[selectedIndex];
const dayShort = current.dataset.dayShort ?? "slot";
const dayLabel = current.dataset.dayLabel ?? "";
const timeRange = current.dataset.timeRange ?? "";
if (bookLabel) bookLabel.textContent = `Book ${dayShort}`;
if (moveFocus) current.focus();
if (announce && status) status.textContent = `Selected ${dayLabel}, ${timeRange} CET.`;
};
radios.forEach((btn, idx) => {
btn.addEventListener("click", () => selectSlot(idx, false, true));
btn.addEventListener("keydown", (ev) => {
if (ev.key === "ArrowDown" || ev.key === "ArrowRight") {
ev.preventDefault();
selectSlot(idx + 1, true, true);
} else if (ev.key === "ArrowUp" || ev.key === "ArrowLeft") {
ev.preventDefault();
selectSlot(idx - 1, true, true);
} else if (ev.key === "Home") {
ev.preventDefault();
selectSlot(0, true, true);
} else if (ev.key === "End") {
ev.preventDefault();
selectSlot(radios.length - 1, true, true);
}
});
});
bookBtn?.addEventListener("click", () => {
const current = radios[selectedIndex];
if (!current) return;
const dayLabel = current.dataset.dayLabel ?? "";
const timeRange = current.dataset.timeRange ?? "";
if (confirmedTitle) confirmedTitle.textContent = `Booked · ${dayLabel}, ${timeRange} CET`;
if (picker) picker.hidden = true;
if (confirmed) confirmed.hidden = false;
if (status) status.textContent = `Booked ${dayLabel} at ${timeRange} CET with ${attendee}.`;
noteToggle?.focus();
});
noteToggle?.addEventListener("click", () => {
if (!noteForm) return;
const willOpen = noteForm.hidden;
noteForm.hidden = !willOpen;
noteToggle.setAttribute("aria-expanded", String(willOpen));
if (willOpen) noteInput?.focus();
});
noteForm?.addEventListener("submit", (ev) => {
ev.preventDefault();
const text = noteInput?.value.trim() ?? "";
if (!text) {
if (status) status.textContent = "Enter an agenda note before saving.";
noteInput?.focus();
return;
}
if (savedNote) {
savedNote.textContent = `Note: ${text}`;
savedNote.hidden = false;
}
noteForm.hidden = true;
noteToggle?.setAttribute("aria-expanded", "false");
if (status) status.textContent = "Agenda note added to the calendar invite.";
});
resetBtn?.addEventListener("click", () => {
if (confirmed) confirmed.hidden = true;
if (noteForm) noteForm.hidden = true;
noteToggle?.setAttribute("aria-expanded", "false");
if (picker) picker.hidden = false;
if (status) status.textContent = "Returned to available meeting slots.";
radios[selectedIndex]?.focus();
});
});
}
initAiSchedules();
document.addEventListener("astro:page-load", initAiSchedules);
</script>When to use
- Proposing a short list of mutual calendar openings directly inside an AI assistant thread
- Showing visual busy blocks for both attendees alongside each highlighted mutual free slot
- Confirming a booking inline while letting the user attach an agenda note or reschedule
When not to use
- Picking from dozens of dates across an entire month; use date-picker or time-slot-picker
- Drafting a free-form scheduling email without calendar availability data; use ai-send
Installation
Add the Haze registry to components.json once, then install AI meeting scheduler with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/ai-schedulenpx shadcn@latest add @haze/ai-scheduleyarn dlx shadcn@latest add @haze/ai-schedulebunx --bun shadcn@latest add @haze/ai-scheduleFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | "haze-ai-schedule" | Unique prefix for radiogroup labels, note form controls, and section IDs. |
| heading | string | "In-chat meeting scheduler" | Screen-reader section heading for landmark navigation. |
| userPrompt | string | "Find 30 minutes with Priya next week for the roadmap" | User prompt asking the assistant to find time. |
| assistantReply | string | "You're both free at these times. Pick one and I'll send the invite." | Assistant reply introducing the candidate time slots. |
| durationLabel | string | "30 min" | Meeting duration label in the card header. |
| timezoneLabel | string | "Your time · CET" | Timezone summary shown on the right of the header. |
| attendee | string | "Priya Nair" | Full attendee name shown in the header and on confirmation. |
| attendeeShort | string | "Priya" | Short row label for the guest availability strip. |
| slots | ScheduleSlot[] | 3 candidate weekday slots | Candidate time slots with calendar badges and busy intervals for You and the guest. |
| class | string | – | Extra classes on the outer section. |
Keyboard interactions
- ArrowUpArrowDownArrowLeftArrowRight
- Move selection across the three candidate meeting slots
- HomeEnd
- Jump to the first or last available meeting slot
- TabEnter
- Book the selected day, toggle Add note, save an agenda note, or Reschedule
Accessibility
- Candidate time slots form a semantic radiogroup with roving tabindex, aria-checked state, and full arrow-key navigation across options.
- Decorative availability strips are marked aria-hidden while each radio exposes the exact day and time range, and booking announces confirmation via a polite status region.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI block "AI meeting scheduler" with `npx shadcn@latest add @haze/ai-schedule`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import AiSchedule from "@/components/haze/blocks/ai-schedule.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/blocks/ai-schedule.md
Customize with real content
Adapt the Haze ai-schedule block for our product. Replace the demo values of these props with our real content: id, heading, userPrompt, assistantReply, durationLabel, timezoneLabel, attendee, attendeeShort, slots, class. Keep the layout, the heading level rules and these accessibility details: Candidate time slots form a semantic radiogroup with roving tabindex, aria-checked state, and full arrow-key navigation across options. Decorative availability strips are marked aria-hidden while each radio exposes the exact day and time range, and booking announces confirmation via a polite status region. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using ai-schedule, check it fits: use it when proposing a short list of mutual calendar openings directly inside an ai assistant thread; showing visual busy blocks for both attendees alongside each highlighted mutual free slot; confirming a booking inline while letting the user attach an agenda note or reschedule. Avoid it when picking from dozens of dates across an entire month; use date-picker or time-slot-picker; drafting a free-form scheduling email without calendar availability data; use ai-send. Alternatives: @haze/time-slot-picker, @haze/date-picker, @haze/ai-send.
Dependencies
- npm: @lucide/astro
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.