1.0.12 • Published 6 months ago

@vj97/react-date-picker v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

React Date Picker

A lightweight plugin to select both Single Date and a Date Range.

Features

  • Single Date Selection
  • Date Range Selection
  • Relative and Absolute Picker Option
  • Search on Relative Option
  • Month/Year Selection View

Demo

See demo here

Screenshots

Date Picker

App Screenshot

Relative Options

App Screenshot

Relative Search

App Screenshot

Absolute Date Picker

App Screenshot

Month Selection

App Screenshot

Year Selection

App Screenshot

Usage/Examples

Import css

import "@vj97/react-date-picker/dist/style.css";

Code Example

import { DatePicker } from '@vj97/react-date-picker'

 <DatePicker 
    placeholder="Choose Date"
    selectionType="range"
    onChange={handleDateChange}
    />

function handleDateChange (dates) {
    console.log(dates)

    // output for single date will be string
    // output for date range will be object as below 
    // {stateDate: "", endDate: ""}
}

Supported props

Property nameTypeDefaultDescription
selectionTypesingle/rangesingleType of the picker
dateFormatstringDD MMM, YYYYThe date format to be returned in the onChange event
viewFormatstringdateFormatThe date format to be shown in the input field
selectedDatesstring/date for single and array of 2 string/date for range, in 'YYYY-MM-DD' formatNULLDate/Range to be selected
minDatestring/dateNULLMinimun date
maxDatestring/datedarkMaximum date
placeholderstringNULLPlaceholder
colorsobject{}Theme colors, refer below for supported colors
showCalendarIconbooleantrueTo show calendar icon on input right
containerStylestyle object{}Style of the input container
inputStylestyle object{}Style of the input
containerClassstringNULLCustom class for input container
inputClassstringNULLCustom class for input
disabledbooleanfalsedisable datepicker input
requiredbooleanfalserequired datepicker input
defaultPickerTyperelative/absoluteabsolutePicker type to be opened be default
onChangefunctionn/aCallback called when date is selected

Colors

{
    selection: "", // Highlight color for selected dates
    text: "", // Text color for picker 
    background: "", // Background color for date picker popup
}