Integration of chakra-ui and react-datepicker
npm install @yamatomo/chakra-react-datepickerIntegration of chakra-ui and react-datepicker
``bash`
yarn add @yamatomo/chakra-react-datepicker react-datepicker
If you use typescript, also install the following packages.
`bash`
yarn add -D @types/react-datepicker
You also need chakra-ui. See the docs for the installation
`tsx
import { DatePicker } from '@yamatomo/chakra-react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';
// or using CSS Modules
// import 'react-datepicker/dist/react-datepicker-cssmodules.css';
const Component = (props) => (
);
`
Usage is the same as react-datepicker. See the docs for details.
You can customize the datepicker style with extendDatePickerTheme props.
`tsx
if (colorMode === 'light') {
// customize header and outside day color
return { ...theme, header: 'pink.400', outsideDay: '#828282' };
}
// dark mode color
return ...
}}
/>
`
| key | light mode value | dark mode value |
|-----------------|------------------|-----------------|
| gray100 | gray.100 | gray.700 |
| gray200 | gray.200 | gray.600 |
| gray300 | gray.300 | gray.500 |
| gray400 | gray.400 | gray.400 |
| gray500 | gray.500 | gray.400 |
| color300 | blue.300 | blue.200 |
| color500 | blue.500 | blue.300 |
| color600 | blue.600 | blue.500 |
| header | white | gray.700 |
| text | gray.800 | whiteAlpha.900 |
| negativeText | whiteAlpha.900 | whiteAlpha.900 |
| monthBackground | white | gray.700 |
| outsideDay | #9f9696 | #9f9696 |
| name | type | description |
|---------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|
| ...react-datepicker props | ReactDatePickerProps | react-datepicker propstodayButton
(Does not support , will be ignored) |undefined \| BoxProps
| rootProps | | for root element props |undefined \| Omit
| inputProps | | input props |undefined \| ResponsiveValue<'xs' \| 'sm' \| 'md' \| 'xl'>
| datePickerSize | | datepicker size.undefined \| "whiteAlpha" \| "blackAlpha" \| "gray" \| "red" \| "orange" \| "yellow" \| "green" \| "teal" \| "blue" \| "cyan" \| "purple" \| "pink" \| "linkedin" \| "facebook" \| "messenger" \| "whatsapp" \| "twitter" \| "telegram"
supported responsive styles |
| datePickerColorSchema | | |undefined \| (colorMode: 'light' \| 'dark', theme: DatePickerTheme) => DatePickerTheme` | |
| extendDatePickerTheme |