React date, time, date range, calender, clock i.e. all in one picker
npm install react-datetime-range-super-picker###### React date, time, date-time range, calender, clock and even month i.e. all in one picker !!
###### This is a _super_ picker due to how it handles date-time props for each components. This component permenantly solves the time handling issue where you get certain format of Date as an input and you have to return completely different format after user edit. Not to forget it does it while looking extremely cool !
###### There are lot of Date Range pickers but most of them do not handle _Date-TIME_ Range picking
Amazing demo just for you ---> Checkout Demo
 
Install using npm simply (If you can just get that long name right...)
``bash`
npm install --save react-datetime-range-super-picker
if you are using yarn
`bash`
yarn add react-datetime-range-super-picker
Install using npm
`bash`
npm install --save lodash date-fns
if you are using yarn
`bash`
yarn add lodash date-fns

---
`tsx
import React, {useState} from 'react'
import { TimePicker } from 'react-datetime-range-super-picker'
import 'react-datetime-range-super-picker/dist/index.css'
const TimePickerWrapper = () => {
const [hour24, setHour] = useState(22)
const [minute, setMin] = useState(30)
// OR use hour (12 hour format), minute and meridian (AM | PM) for props
// OR for string time use : "HH:mm" ( 24 hrs ) | "hh:mm aa" ( 12 hrs )
const handleTimeUpdate = ({time}) => {
setHour(time.hour24)
setMin(time.minute)
}
return (
)
}
`
Available Props:
| Props | Type | Description |
| :--- | :---:| :--- |
| time |
Supports Input component : TimePickerInput . Checkout further details
`tsx
import React, {useState} from 'react'
import { DatePicker } from 'react-datetime-range-super-picker'
import 'react-datetime-range-super-picker/dist/index.css'
const DatePickerWrapper = () => {
const [curr_date, setDate] = useState(new Date())
// OR use JSON object with : day, month, year
const handleDateUpdate = ({date}) => {
setDate(date)
}
return (
onDateUpdate={handleDateUpdate} />
)
}
`
Available Props:
| Props | Type | Description |
| :--- | :---:| :--- |
| date |
Supports Input component : DatePickerInput . Checkout further details
`tsx
import React, {useState} from 'react'
import { DateTimePicker } from 'react-datetime-range-super-picker'
import 'react-datetime-range-super-picker/dist/index.css'
const DateTimePickerWrapper = () => {
const [curr_date, setDate] = useState(new Date())
// OR use JSON object with : day, month, year
const handleDateUpdate = ({date}) => {
setDate(date.date)
}
return (
)
}
`
Available Props:
| Props | Type | Description |
| :--- | :---:| :--- |
| date |
Supports Input component : DateTimePickerInput . Checkout further details
`tsx
import React, {useState} from 'react'
import { DateRangeCalendarPicker } from 'react-datetime-range-super-picker'
import 'react-datetime-range-super-picker/dist/index.css'
const DateRangeCalendarPickerWrapper = () => {
const [from_date, setFromDate] = useState(new Date())
const [to_date, setToDate] = useState(new Date())
// OR use JSON object with : day, month, year
const handleFromDateUpdate = ({date}) => {
setFromDate(date.date)
}
const handleToDateUpdate = ({date}) => {
setToDate(date.date)
}
return (
onToDateUpdate={handleToDateUpdate} />
)
}
`
Available Props:
| Props | Type | Description |
| :--- |:---:| :--- |
| from_date,
to_date |
Supports Input component : DateRangeCalendarPickerInput . Checkout further details
`tsx
import React, {useState} from 'react'
import { DateTimeRangePicker } from 'react-datetime-range-super-picker'
import 'react-datetime-range-super-picker/dist/index.css'
const DateTimeRangePickerWrapper = () => {
const [from_date, setFromDate] = useState(new Date())
const [to_date, setToDate] = useState(new Date())
// OR use JSON object with : day, month, year
const handleFromDateUpdate = ({date}) => {
setFromDate(date.date)
}
const handleToDateUpdate = ({date}) => {
setToDate(date.date)
}
return (
onToDateTimeUpdate={handleToDateUpdate} />
)
}
`
Available Props:
| Props | Type | Description |
| :--- |:---:| :--- |
| from_date,
to_date |
Supports Input component : DateTimeRangePickerInput . Checkout further details
###### Bonus Month picker! Useful when you want to pick just month and year in a cool way.
`tsx
import React, {useState} from 'react'
import { MonthPicker } from 'react-datetime-range-super-picker'
import 'react-datetime-range-super-picker/dist/index.css'
const MonthPickerWrapper = () => {
const [res_month, setMonth] = useState(4)
const [res_year, setYear] = useState(2020)
// OR use Date object as input
const handleUpdate = ({month, year}) => {
setMonth(month)
setYear(year)
}
return (
)
}
`
Available Props:
| Props | Type | Description |
| :--- | :---:| :--- |
| time | Date OR Object | Example
`tsx
import React, {useState} from 'react'
import { DateRangePicker } from 'react-datetime-range-super-picker'
import 'react-datetime-range-super-picker/dist/index.css'
const DateRangePickerWrapper = () => {
const [from_date, setFromDate] = useState(new Date())
const [to_date, setToDate] = useState(new Date())
// OR use JSON object with : day, month, year
const handleFromDateUpdate = ({date}) => {
setFromDate(date.date)
}
const handleToDateUpdate = ({date}) => {
setToDate(date.date)
}
return (
onToDateUpdate={handleToDateUpdate} />
)
}
`
Available Props:
| Props | Type | Description |
| :--- |:---:| :--- |
| from_date,
to_date |
Supports Input component : DateRangePickerInput . Checkout further details
Input components are wrapper around their picker components. They handle show / hide states and logic internally.
If you want to show a simple form input box, which will show or hide Picker component as per user interaction than use Input components.
List of Input Components : TimePickerInput, DatePickerInput, DateTimePickerInput, DateTimeRangePickerInput.
Here is an example code for DateTimeRangePickerInput component.
`tsx
import React, {useState} from 'react'
import { DateTimeRangePickerInput } from 'react-datetime-range-super-picker'
import 'react-datetime-range-super-picker/dist/index.css'
const DateTimeRangePickerInputWrapper = () => {
const [from_date, setFromDate] = useState(new Date())
const [to_date, setToDate] = useState(new Date())
// OR use JSON object with : day, month, year
const handleFromDateUpdate = ({date}) => {
setFromDate(date.date)
}
const handleToDateUpdate = ({date}) => {
setToDate(date.date)
}
return (
onToDateTimeUpdate={handleToDateUpdate} />
)
}
``
Every Input component takes the same props as simple picker component.
In addition it provides extra props for styling. Which are as listed below.
| Props | Description |
| :--- | :--- |
| inputStyle | Pass styles directly to text box input component as Json object. Follows same rules as React style object. |
| popupStyle | Pass styles directly to picker popup wrapper component as Json object. Can be used to position, resize wrapper. Follows same rules as React style object. |
| className | String, css class to be used apply additional style to text box with raw css |
| popupClassName | String, css class to be used apply additional style to picker popup with raw css |
| isDisabled | Boolean, to control input model show |
| inputComponent | React Component, to render custom input |
Note : All of above props are optional.
Every picker component color scheme can be changed with 2 props: theme and colors.
Currently all picker supports few themes out of the box as shown in props table below. (More themes coming soon !!)
Theme is created using colors listed in props table below.
There are 3 easy ways to customise color scheme to suit your requirements:
1. Use theme prop if that matches your needs.
2. Use all the colors and customise whole picker look.
3. Use theme prop and override just the colors you want to change in that theme. i.e. choose "dark" _theme_ and just override _primary color_
| Props | Type | Description |
| :--- | :---:| :--- |
| theme | String | light, dark, colorful
Default is light |
| colors | Json Object | Json object keys :
All styling props above are optional
1. Light (Default)



###### Things that this date time range super picker library does not do (YET).
###### We are open to suggestions. Open an issue with your ideas, if we like it and it is really useful ( or just cool ) we will implement it in next release !
* Filter props to handle disable / enable pickable dates
* Time duration component with range picker
* "Last X days/hours" dynamic selector for range picker
- Dishant Chavda : Creator
- Harsh Darji : Contributions with styling updates and setting up the demo
---
MIT © Dishant15