logoReact Custom UI

Datepicker

A Datepicker component simplifies date selection for users by providing a calendar interface within your application. It enhances user experience by streamlining the process of inputting dates and ensuring accuracy. Datepickers commonly include features such as date range selection and accessibility support.

Installation

To get started, install the Datepicker via npm:
npm i react-custom-ui-datepicker
Or via yarn:
yarn add react-custom-ui-datepicker

RangeMode

<Datepicker range={true} />

Without Buttons

<Datepicker config={{ calendarFormat: { hideActionButtons: true } }} />

Small Size

<Datepicker size="small" />

Props Available

PropsOptionsDescription
variant'light' | 'dark' | 'custom'Theme in light, dark or custom mode
size'small'Size of the datepicker
range'true' | 'false'Enable the datepicker range mode
onChangeDatefunctionFunction to handle the date change
datevariableValue of the date state
disabledbooleanDisable the datepicker
placeholderstringThe datepicker input placeholder
configobjectThe datepicker configuration

Config Props

PropsOptionsDescription
locale'fr' | 'de' | 'en-AU' | 'en-CA' | 'en-GB' |
'en-US' | 'es' | 'pl' | 'pt' | 'pt-BR' | 'ru'
The datepicker language
dateFormat'MM/dd/yyyy' | 'dd/MM/yyyy' | dd/MM/yyyy HH:mm' | etcThe date format in the output of the datepicker. Able to use any format from the date-fns library.
inputStylesCheck Input StylesThe input styles, check the Input Props table for more details.
calendarStylesCheck Calendar StylesThe calendar styles, check the Calendar Styles Props table for more details.
calendarFormatCheck Calendar FormatThe calendar format, check the Calendar Format Props table for more details.

Input Styles

PropsOptionsDescription
backgroundColorCSS background-color
borderColorCSS border-color
placeholderColorCSS ::placeholder and define the color
textColorCSS color
errorConfigCheck Error Config PropsDefine the config of the error on wrong dates on the datepicker
focusConfigCheck Focus Config PropsDefine the config of the focus on the input
disabledConfigCheck Disabled Config PropsDefine the config of the disabled styles on the input

Error Config Props

PropsOptionsDescription
errorTextstringThe error message to display when the date is invalid
errorTextColorThe error text color
errorTextSizeAny font-sizeThe error text size
errorBorderColorThe error border-color on the input
hideError'true' | 'false'Hide the error
hideErrorIcon'true' | 'false'Hide the error icon

Focus Config Props

PropsOptionsDescription
focusTextColorThe text color when the input is focused
focusIconColorThe calendar icon color when the input is focused
focusBorderColorThe input border-color when it is focused

Disabled Config Props

PropsOptionsDescription
disabledTextColorThe text color when the input is disabled
disabledIconColorThe calendar icon color when the input is disabled
disabledBackgroundColorThe input background-color when it is disabled
disabledBorderColorThe input border-color when it is disabled

Calendar Styles

PropsOptionsDescription
calendarBackgroundThe calendar background-color
headerIconsColorThe header icons color
headerTextColorThe header text color
headerTextWeightAll font-weight cssThe header text weight
headerTextSizeAll font-size cssThe header text size
daysOfWeekColorThe days of the week color
daysOfWeekSize All font-size css
daysOfWeekWeightAll font-weight cssThe days of the week font-weight
inactiveDaysColorThe inactive days color
hideInactiveDays'true' | 'false'Hide the inactive days
dayRadiusAll sizes of css border-radiusThe days border-radius
dayColorThe days text color
daySizeAll font-size cssThe days font-size
dayWeightAll font-weight cssThe days font-weight
dayHoverColorThe days text color when hovering
rangeHoverColorThe range hover color
applyBtnTextAny string textThe apply button text
applyBtnTextColorThe apply button text color
applyBtnBorderColorThe apply button border-color
applyBtnBackgroundColorThe apply button background-color
applyBtnHoverTextColorThe apply button hover text color
applyBtnHoverBackgroundColorThe apply button hover background-color
applyDisabledBtnBackgroundColorThe apply button disabled background-color
applyDisabledBtnTextColorThe apply button disabled text color
applyDisabledBtnBorderColorThe apply button disabled border-color
applyDisabledBtnHoverTextColorThe apply button disabled hover text color
applyDisabledBtnCursorAll cursor css styleThe apply button disabled cursor
cancelBtnTextAny string textThe cancel button text
cancelBtnTextColorThe cancel button text color
cancelBtnBorderColorThe cancel button border-color
cancelBtnBackgroundColorThe cancel button background-color
cancelBtnHoverTextColorThe cancel button hover text color
cancelBtnHoverBackgroundColorThe cancel button hover background-color
selectedDayColorThe selected day color
selectedDayBackgroundColorThe selected day background-color
todayColorThe today color
todayBorderColorThe today border-color
todayBorderRadiusAll sizes of css border-radiusThe today border-radius

Calendar Format

PropsOptionsDescription
hideActionButtons'true' | 'false'Hide the action buttons
daysOfWeekFormat'EEEE' | 'EEEEE' | 'EEEEEE'The days of the week format
daysHeaderMonth'M' | 'Mo' | 'MM' | 'MMM' | 'MMMM' | 'MMMMM'The days header month format
daysHeaderYear'y' | 'yo' | 'yy' | 'yyy' | 'yyyy' | 'yyyyy'The days header year format