Chakra UI + Dayzed = datepicker
This article discusses a simple Chakra Datepicker based on Dayzed. The component is built using Chakra UI and is designed to respect all Chakra UI Configs without any issues. The component also utilizes a date library and provides the option to customize the source code as per individual requirements.
To use the Chakra Datepicker component, follow these steps:
Install the dependency using either npm or Yarn:
npm install chakra-datepicker
yarn add chakra-datepicker
Basic Usage: Implement the Datepicker component in your code by importing it.
import DatePicker from 'chakra-datepicker';
Single Range Selection: Note that during the selection process, the list will have only one value. To ensure proper functioning, avoid controlling it directly using [startDate, endDate]
. Instead, set the selectedDates
prop to [intermediateSelection]
.
Configurations: Various configurations can be applied to the Datepicker component using the following props:
dateNavBtnProps
: Extends from ButtonProps of Chakra UI, allowing for custom behavior modifications.dayOfMonthBtnProps
: Customize the date button style based on the state using this prop.popoverCompProps
: Useful for setting up simple global styles like text color.The Chakra Datepicker component based on Dayzed provides a simple and customizable solution for implementing date selection functionality. Built using Chakra UI, the component ensures compatibility with Chakra UI Configs. It also incorporates a date library and offers various props for customization. The installation process is straightforward, and developers can easily modify the source code to tailor the component as needed.