Componentpickers1.79 KB gzipZero dependencies
DateRangePicker
Two-month mini calendar grid for selecting start and end dates with nights count
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add date-range-pickerOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { DateRangePicker } from "@/components/ui/date-range-picker"; <DateRangePicker defaultValue={[{ start: new Date(2024, 0, 1), end: new Date(2024, 0, 7)}]} onValueChange={(v) => {}} />Source code
date-range-picker.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxdate-range-picker.tsx234 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface DateRangePickerProps extends Omit<React.HTMLAttributes<HTMLElement>, "value" | "defaultValue"> { value?: [Date, Date]; defaultValue?: [Date, Date]; onValueChange?: (value: [Date, Date] | undefined) => void; min?: Date; max?: Date; className?: string;} const MONTHS = [ "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER",];Props
| Prop | Type | Description |
|---|---|---|
| value | [Date, Date] | Controlled value. |
| defaultValue | [Date, Date] | Initial value when uncontrolled. |
| onValueChange | (value: [Date, Date] | undefined) => void | Callback invoked on value change. |
| min | Date | Minimum allowed numeric or date bound. |
| max | Date | Maximum allowed numeric or date bound. |
| className | string | Optional Tailwind or custom CSS classes merged with component styles. |