# react-calendario A modern, flexible, and highly customizable calendar component library for React with TypeScript support. ## Features - 📅 **Multiple Views**: Year, Month, Week, and custom date ranges - 🎨 **Highly Customizable**: Multiple header styles, sizes, and visual options - 🔍 **Interactive**: Date selection, range picking, and click handlers - 📱 **Responsive**: Works on all screen sizes - 🎯 **TypeScript**: Full type safety and IntelliSense support - 🎨 **Themeable**: Customizable colors and styles - 📦 **Lightweight**: Minimal dependencies ## Installation ```bash npm install react-calendario date-fns classnames ``` or ```bash yarn add react-calendario date-fns classnames ``` ## Quick Start ```tsx import { Month } from 'react-calendario'; function App() { return ( ); } ``` ## Components ### Year Display a full year calendar with customizable month grid. ```tsx import { Year } from 'react-calendario'; ``` ### Month Display a single month with various layout options. ```tsx import { Month } from 'react-calendario'; ``` ### Week Display a single week view. ```tsx import { Week } from 'react-calendario'; ``` ### DateRange Display a custom date range with optional selection and interactivity. ```tsx import { DateRange } from 'react-calendario'; console.log('Clicked:', date)} activeDates={[new Date(2024, 0, 17)]} /> ``` ## Props ### Common Props All components share these common props: | Prop | Type | Default | Description | |------|------|---------|-------------| | `size` | `'xl' \| 'l' \| 'm' \| 's' \| 'xs' \| 'xxs'` | `'l'` | Day cell size | | `fontProportion` | `number` | `100` | Font size percentage (10-100) | | `magnify` | `boolean` | `false` | Enable magnify effect on selection | | `weekendDays` | `number[]` | `[6, 0]` | Weekend day indices (0=Sunday) | ### Header Styles | Style | Description | |-------|-------------| | `'expanded'` | Full day names (e.g., "Monday") | | `'compacted'` | Three-letter abbreviations (e.g., "Mon") | | `'tiny'` | Two-letter abbreviations (e.g., "Mo") | | `'none'` | Numbers only | ### Size Options - `'xxs'`: Extra extra small (20px height, 1:1.5 header:content ratio) - `'xs'`: Extra small (24px height) - `'s'`: Small (28px height) - `'m'`: Medium (32px height) - `'l'`: Large (36px height) - `'xl'`: Extra large (48px height) ## Advanced Usage ### Date Range Selection ```tsx import { useState } from 'react'; import { Year } from 'react-calendario'; function DateRangePicker() { const [dateRange, setDateRange] = useState({ startDate: null, endDate: null, selecting: false, hoverDate: null, anchorDate: null }); const handleDateSelect = (date) => { // Your range selection logic }; return ( setDateRange(prev => ({ ...prev, hoverDate: date }))} /> ); } ``` ### Interactive Date Range with Active States ```tsx import { DateRange } from 'react-calendario'; function InteractiveCalendar() { const [activeDates, setActiveDates] = useState([]); const handleDateClick = (date) => { setActiveDates(prev => { const exists = prev.some(d => d.getTime() === date.getTime()); return exists ? prev.filter(d => d.getTime() !== date.getTime()) : [...prev, date]; }); }; return ( ); } ``` ## Styling The components use CSS modules and CSS variables for theming. You can override the default styles by: 1. Using the built-in props for common customizations 2. Overriding CSS variables in your global styles 3. Applying custom CSS classes ### CSS Variables ```css :root { --color-primary: #2196f3; --color-primary-dark: #1976d2; --color-selected: #e3f2fd; /* ... and more */ } ``` ## TypeScript Full TypeScript support with exported types: ```tsx import type { DateRange, HeaderStyle, DaySize, MonthCutoffType } from 'react-calendario'; ``` ## License MIT ## Contributing Contributions are welcome! Please feel free to submit a Pull Request.