Calendar
poyraz/calendarFreeComponent
Poyraz Soft Glass calendar with semantic states and composable variants.
Install it
npx shadcn@latest add https://ui.poyrazavsever.com/r/calendar.jsonSource
1"use client";23import * as React from "react";4import { ChevronLeft, ChevronRight } from "lucide-react";56import { cn } from "@/lib/utils";7import { Button } from "@/components/ui/atoms/button";89/* ================================================================== */10/* HELPERS */11/* ================================================================== */1213const DAYS = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"];14const MONTHS = [15 "January",16 "February",17 "March",18 "April",19 "May",20 "June",21 "July",22 "August",23 "September",24 "October",25 "November",26 "December",27];28const MONTHS_SHORT = [29 "Jan",30 "Feb",31 "Mar",32 "Apr",33 "May",34 "Jun",35 "Jul",36 "Aug",37 "Sep",38 "Oct",39 "Nov",40 "Dec",41];4243function getDaysInMonth(year: number, month: number) {44 return new Date(year, month + 1, 0).getDate();45}4647function getFirstDayOfWeek(year: number, month: number) {48 const day = new Date(year, month, 1).getDay();49 // Convert Sunday=0 to Monday-first (Mon=0 … Sun=6)50 return day === 0 ? 6 : day - 1;51}5253function isSameDay(a: Date, b: Date) {54 return (55 a.getFullYear() === b.getFullYear() &&56 a.getMonth() === b.getMonth() &&57 a.getDate() === b.getDate()58 );59}6061function isToday(date: Date) {62 return isSameDay(date, new Date());63}6465type CalendarView = "days" | "months" | "years";6667/* ================================================================== */68/* CALENDAR */69/* ================================================================== */7071export interface DateRange {72 from?: Date;73 to?: Date;74}7576interface CalendarBaseProps {77 /** Minimum selectable date */78 minDate?: Date;79 /** Maximum selectable date */80 maxDate?: Date;81 className?: string;82 surface?: "plain" | "solid" | "soft" | "glass";83 radius?: "none" | "sm" | "md" | "lg" | "xl";84 size?: "compact" | "default" | "spacious";85 initialMonth?: Date;86 onMonthChange?: (month: Date) => void;87}8889export interface CalendarSingleProps extends CalendarBaseProps {90 mode?: "single";91 selected?: Date;92 defaultSelected?: Date;93 onSelect?: (date: Date | undefined) => void;94}9596export interface CalendarRangeProps extends CalendarBaseProps {97 mode: "range";98 selected?: DateRange;99 defaultSelected?: DateRange;100 onSelect?: (range: DateRange | undefined) => void;101}102103export type CalendarProps = CalendarSingleProps | CalendarRangeProps;104105// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from poyraz
All 71 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | poyraz | Components | Free | 2 deps | |
| Alertalert | poyraz | Components | Free | 2 deps | |
| Announcement Barannouncement-bar | poyraz | Components | Free | 2 deps | |
| Autocompleteautocomplete | poyraz | Components | Free | 1 dep | |
| Avataravatar | poyraz | Components | Free | 2 deps | |
| Badgebadge | poyraz | Components | Free | 1 dep | |
| Bg Patternbg-pattern | poyraz | Components | Free | no deps | |
| Breadcrumbbreadcrumb | poyraz | Components | Free | 1 dep |
