Loading...
Installation
Usage
import { MultiMonthCalendar } from "@/components/ruixen/multi-month-calendar";
import { useState } from "react";
import { DateRange } from "react-day-picker";
export default function App() {
const [range, setRange] = useState<DateRange | undefined>();
const [single, setSingle] = useState<Date | undefined>();
return (
<div className="space-y-6">
{/* Range Mode */}
<MultiMonthCalendar
numberOfMonths={3}
mode="range"
selected={range}
onSelect={(date) => setRange(date)}
/>
{/* Single Mode */}
<MultiMonthCalendar
numberOfMonths={2}
mode="single"
selected={single}
onSelect={(date) => setSingle(date)}
/>
</div>
);
}
Props
Prop | Type | Default | Description |
---|---|---|---|
numberOfMonths | number | 2 | Number of months to display |
mode | "single" | "range" | "single" | Selection mode |
selected | Date | DateRange | undefined | - | Selected date(s) |
onSelect | (date: Date | DateRange | undefined) => void | - | Callback when date is selected |
showOutsideDays | boolean | true | Show days outside current month |
className | string | - | Additional CSS classes |
Features
- Multiple Months: Display 2+ months simultaneously
- Year/Month Dropdowns: Quick navigation to any year/month
- Dual Mode Support: Single date or range selection
- Responsive Design: Adapts to different screen sizes
- Keyboard Navigation: Full keyboard accessibility
- Custom Styling: Tailwind CSS classes for easy customization