1.0.9 • Published 3 months ago

daterange-picker-reactjs v1.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
3 months ago

React date and date-range picker

Features

  • Easily customized and add unique styles with Tailwindcss
  • Lightweight
  • Typescript support
  • Select date ranges across multiple months
  • Keyboard navigation

Example image

Usage/Examples

Date Picker

import { DatePicker } from "daterange-picker-reactjs";

function App() {
  return (
    <DatePicker 
        preSelectedDate={new Date(2025, 1, 12)} 
        onChange={(date) => console.log(date)}
        weekStartsOn = 0,
        customDaysOfWeek = {['S', 'M', 'T', 'W', 'T', 'F', 'S']}
    />
  )
}

NOTE: When customizing the customDaysOfWeek prop, make sure the start
day coincides with the weekStartsOn prop. Eg, if customDaysOfWeek's first 
day starts on Monday, the weekStartsOn value should be 1.

DatePicker Props

NameDescriptionTypeisRequiredDefault
preSelectedDateDefault date selectedDatenullnull
isSelectedStyleStyle for highlighting selected datestringfalsebg-blue-500 text-white
onChangeCallback for returning your selected date. Takes in a date propFunctiontrue-
weekStartsOnStart day of the weekNumberfalse0
customDaysOfWeekCustomize week namesstring[]false"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
containerStyleCSS rules for styling calendar containerStringfalsepy-4 px-2 border rounded shadow-md
disabledDateDate to be unselectableDatefalsenull
showYearMonthDividerOpt in to have the year/month divider visible or notbooleanfalsetrue
daysOfWeekStylesCustom styles for days of the weekstringfalsetext-center font-medium text-black/70
visibleDatesStyleStyle for dates in the monthstringfalsehover:bg-blue-100 cursor-pointer
prevMonthBtnIconSome icon/component to fit into the button for navigating to previous monthsReact.ReactNodefalseChevron-left icon
nextMonthBtnIconSome icon/component to fit into the button for navigating to nextious monthsReact.ReactNodefalseChevron-right icon
outlineStyleCustom outline style to be applied on all focused statesstringfalseoutline-blue-500

DateRange Picker

import { DateRangePicker } from "daterange-picker-reactjs";

function App() {
  return (
    <DateRangePicker
        onRangeChange={(range) => console.log("Selected Range:", range)}
        disabledDates={[
          new Date(2024, 11, 25),
          new Date(2024, 0, 1),
        ]}
        customDaysOfWeek={['S', 'M', 'T', 'W', 'T', 'F', 'S']}
        preSelectedRange={{
          start: new Date(2025, 0, 12),
          end: new Date(2025, 1, 12),
        }}
        monthTitleStyle="text-red-500 uppercase"
        daysOfWeekStyles="text-red-700"
        endDateStyle="bg-red-500 text-white rounded-r-full"
        isCurrentMonthStyle="text-red-900 hover:bg-red-500"
        visibleMonths={3}
        weekStartsOn={0} // Week starts on Sunday
    />
  )
}

DateRangePicker Props

NameDescriptionTypeisRequiredDefault
onRangeChangeCallback for returning your selected range. Takes in a range propFunctiontrue-
disabledDatesArray of dates to be unselectableDate[]falsenull
customDaysOfWeekCustomize week namesstring[]false"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
preSelectedRangeHighlight a range of dates preselected on render. Great for when editing{ start: Date; end: Date }falsenull
startDateStyleStyling for first day of rangestringfalsebg-blue-500 text-white rounded-l-full
inRangeStylesStyling for dates in range other than first and last datesstringfalsebg-blue-200 text-blue-800
endDateStyleStyling for last day of rangestringfalsebg-blue-500 text-white rounded-r-full
visibleDatesStyleStyling for dates visiblestringfalsesome css classes
daysOfWeekStylesStyling for days of the weekstringfalsefont-medium text-black/70
monthTitleStyleStyling for month name and year titlestringfalsetext-center font-semibold
containerStyleCSS rules for styling calendar containerStringfalsepy-4 px-2 border rounded shadow-md
visibleMonthsThe number of months to show at a timenumberfalse2
weekStartsOnPreferred start day of the weeknumberfalse0
prevMonthBtnIconSome icon/component to fit into the button for navigating to previous monthsReact.ReactNodefalseChevron-left icon
nextMonthBtnIconSome icon/component to fit into the button for navigating to nextious monthsReact.ReactNodefalseChevron-right icon
outlineStyleCustom outline style to be applied on all focused statesstringfalseoutline-blue-500
showYearMonthDividerOpt in to have the year/month divider visible or notbooleanfalsetrue
1.0.9

3 months ago

1.0.8

4 months ago

1.0.7

4 months ago

1.0.6

4 months ago

1.0.5

4 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago