Calendar 1
shadcnstore/calendar-1FreeBlock
A month grid with event chips, a day popover and a create-event dialog
Install it
npx shadcn@latest add https://shadcnstore.com/r/calendar-1.jsonSource
1'use client'23import { useMemo, useState } from 'react'4import { ChevronLeft, ChevronRight, Plus } from 'lucide-react'5import { Button } from '@/components/ui/button'6import { calendarEvents, categoryToken, type EventCategory } from "@/components/data/calendar-1-data"7import { Calendar1EventDialog } from './calendar-1-event-dialog'8import { Calendar1MonthGrid } from './calendar-1-month-grid'910const monthFormat = new Intl.DateTimeFormat('en-US', { month: 'long', year: 'numeric' })1112const startOfDay = (date: Date) => new Date(date.getFullYear(), date.getMonth(), date.getDate())1314const addDays = (date: Date, days: number) => {15 const next = new Date(date)16 next.setDate(next.getDate() + days)17 return next18}1920/** Weeks start on Monday, which is what most of the world outside the US expects. */21function monthGrid(anchor: Date) {22 const first = new Date(anchor.getFullYear(), anchor.getMonth(), 1)23 const offset = (first.getDay() + 6) % 724 const start = addDays(first, -offset)2526 return Array.from({ length: 42 }, (_, index) => addDays(start, index))27}2829export function Calendar1() {30 const today = useMemo(() => startOfDay(new Date()), [])31 const [anchor, setAnchor] = useState(() => new Date(today.getFullYear(), today.getMonth(), 1))32 const [creating, setCreating] = useState<Date | null>(null)3334 const events = useMemo(35 () =>36 calendarEvents.map(event => ({37 ...event,38 date: addDays(today, event.dayOffset),39 })),40 [today],41 )4243 const days = useMemo(() => monthGrid(anchor), [anchor])4445 return (46 <div className='w-full p-4 sm:p-6'>47 <div className='mx-auto max-w-5xl'>48 <div className='flex flex-wrap items-center justify-between gap-3'>49 <div className='flex items-center gap-2'>50 <h1 className='text-2xl font-semibold tracking-tight'>{monthFormat.format(anchor)}</h1>51 </div>5253 <div className='flex items-center gap-2'>54 <Button55 variant='outline'56 size='icon'57 aria-label='Previous month'58 onClick={() => setAnchor(new Date(anchor.getFullYear(), anchor.getMonth() - 1, 1))}59 >60 <ChevronLeft className='size-4' />61 </Button>62 <Button variant='outline' onClick={() => setAnchor(new Date(today.getFullYear(), today.getMonth(), 1))}>63 Today64 </Button>65 <Button66 variant='outline'67 size='icon'68// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from ShadcnStore
All 228 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| About 1about-1 | ShadcnStore | Blocks | Free | 1 dep · 3 files | |
| About 2about-2 | ShadcnStore | Blocks | Paid | 2 deps · 3 files | |
| AI Chat 1ai-chat-1 | ShadcnStore | Blocks | Free | 2 deps · 4 files | |
| AI Chat 2ai-chat-2 | ShadcnStore | Blocks | Paid | 1 dep · 4 files | |
| AI Prompt 1ai-prompt-1 | ShadcnStore | Blocks | Paid | 1 dep · 3 files | |
| App Dashboard 1app-1 | ShadcnStore | Blocks | Free | 1 dep · 4 files | |
| Task Management 2app-2 | ShadcnStore | Blocks | Paid | 2 deps · 4 files | |
| Foundational Application Shellapp-shell-1 | ShadcnStore | Blocks | Free | 1 dep · 4 files |
