Aurora Calendar
aurora-dinglebear-ai/aurora-calendarUnverifiedComponent
Compact month calendar with Aurora focus, selected-day, and operator-friendly density.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/dinglebear-ai/aurora/main/aurora-calendar.jsonSource
1"use client"23import * as React from "react"4import { ChevronLeft, ChevronRight } from "lucide-react"5import { Button } from "@/registry/aurora/ui/button"67export interface CalendarProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onSelect"> {8 month?: Date9 selected?: Date10 onSelect?: (date: Date) => void11 onMonthChange?: (month: Date) => void12}1314function sameDay(a?: Date, b?: Date) {15 return Boolean(a && b && a.toDateString() === b.toDateString())16}1718/**19 * Build the visible month grid as weeks of 7 cells. Leading days before the 1st20 * and trailing days after the last day of the month are rendered as empty cells21 * (CD shows only the current month's dates — no greyed adjacent-month days).22 */23function buildCells(month: Date): (Date | null)[] {24 const year = month.getFullYear()25 const m = month.getMonth()26 const firstWeekday = new Date(year, m, 1).getDay()27 const daysInMonth = new Date(year, m + 1, 0).getDate()2829 const cells: (Date | null)[] = []30 for (let i = 0; i < firstWeekday; i += 1) cells.push(null)31 for (let day = 1; day <= daysInMonth; day += 1) cells.push(new Date(year, m, day))32 while (cells.length % 7 !== 0) cells.push(null)33 return cells34}3536export function Calendar({ month, selected, onSelect, onMonthChange, className, style, ...props }: CalendarProps) {37 const [internalVisibleMonth, setInternalVisibleMonth] = React.useState(month ?? new Date())38 const visibleMonth = month ?? internalVisibleMonth39 const cells = buildCells(visibleMonth)40 const formatter = new Intl.DateTimeFormat(undefined, { month: "long", year: "numeric" })41 const today = new Date()4243 const handleMonthChange = React.useCallback(44 (nextMonth: Date) => {45 if (month === undefined) {46 setInternalVisibleMonth(nextMonth)47 }48 onMonthChange?.(nextMonth)49 },50 [month, onMonthChange]51 )5253 return (54 <div55 className={["grid gap-4 border p-4", className].filter(Boolean).join(" ")}56 style={{57 width: "320px",58 borderRadius: "16px",59 background: "var(--aurora-panel-medium)",60 borderColor: "var(--aurora-border-default)",61 color: "var(--aurora-text-primary)",62 boxShadow: "var(--aurora-shadow-medium), var(--aurora-highlight-medium)",63 ...style,64 }}65 {...props}66 >67 <div className="flex items-center justify-between gap-2">68 <Button69 type="button"70 variant="neutral"71 size="icon"72 aria-label="Previous month"73// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from aurora
All 176 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Aurora Accordionaurora-accordion | aurora | Components | Unverified | 2 deps | |
| Aurora Alert Dialogaurora-alert-dialog | aurora | Components | Unverified | 2 deps | |
| Aurora Aspect Ratioaurora-aspect-ratio | aurora | Components | Unverified | no deps | |
| Aurora Avataraurora-avatar | aurora | Components | Unverified | 1 dep | |
| Aurora Badgeaurora-badge | aurora | Components | Unverified | 2 deps | |
| Aurora Banneraurora-banner | aurora | Components | Unverified | 1 dep | |
| Aurora Breadcrumbaurora-breadcrumb | aurora | Components | Unverified | 2 deps | |
| Aurora Buttonaurora-button | aurora | Components | Unverified | 2 deps |
