T React Date Picker
A simple React
date-picker component written with styled-component
💅 and date-fns
🗓.
Props
This component accepts the following three props:
- onSelect:(fn) function that will receive the selected date
- value:(Date) The current value selected by the user
- dateFormat(String,optional): The specific format you would like to display the date value. The possible formats are determined by
date-fns
. Consult their documentation for the possible formats. defaults to'ddddd Do [of] MMMM YYYY'
which outputsMon 12th of June 2018
.
Usage
The most basic usage of this component is found below.
; Component state = value: null ; { return <DatePicker value=thisstatevalue onSelect= this /> ; }
Custom styles
You can override the styles to the main form field using styled-components
in the following manner:
; ; const StyledPicker = ` background-color: pink;`; { return <StyledPicker/>} //renders a DatePicker with a pink background