JollyUI
  1. Docs
  2. components
  3. Date Picker

Date Picker

A date picker component with range and presets.

Installation

npx @sly-cli/sly add jolly-ui date-picker

Note: Only the default style can be installed via CLI at the moment

Usage

"use client"
 
import React from "react"
import { type DateValue } from "react-aria-components"
 
import {
  Calendar,
  CalendarCell,
  CalendarGrid,
  CalendarGridBody,
  CalendarGridHeader,
  CalendarHeaderCell,
  CalendarHeading,
} from "@/registry/default/ui/calendar"
import {
  DatePicker,
  DatePickerButton,
  DatePickerContent,
} from "@/registry/default/ui/date-picker"
 
export default function DatepickerDemo({ ...props }) {
  const [date, setDate] = React.useState<DateValue>()
 
  return (
    <DatePicker shouldCloseOnSelect={false} onChange={setDate} {...props}>
      <DatePickerButton date={date} />
      <DatePickerContent>
        <Calendar>
          <CalendarHeading />
          <CalendarGrid>
            <CalendarGridHeader>
              {(day) => <CalendarHeaderCell>{day}</CalendarHeaderCell>}
            </CalendarGridHeader>
            <CalendarGridBody>
              {(date) => (
                <>
                  <CalendarCell date={date} />
                </>
              )}
            </CalendarGridBody>
          </CalendarGrid>
        </Calendar>
      </DatePickerContent>
    </DatePicker>
  )
}

Examples

Date Picker

Date Range Picker

With Presets