Date picker
Date picker component with an accessible calendar, a range mode that highlights every day between two dates, min and max dates, locale support and keyboard navigation.
How to use it
Run npx @blossomui/react add date-picker, or copy src/components/UI/DatePicker/DatePicker.tsx into your React project and import it.
import { DatePicker, DateRangePicker } from './components/ui/DatePicker'Props
DatePickerLabels
| Prop | Type | Description |
|---|---|---|
| choose (required) | string | Accessible name of the calendar. |
| previousMonth (required) | string | |
| nextMonth (required) | string | |
| firstDay (required) | string | Hint of the range picker while it waits for the first day. |
| lastDay (required) | string | Hint of the range picker while it waits for the last day. |
DatePickerProps
| Prop | Type | Description |
|---|---|---|
| required | boolean | Marks the field as required: an asterisk is shown next to the label. |
| hint | string | Helper text shown under the field. |
| error | string | Error message. It is shown in red under the field and marks it as invalid. |
| labels | Partial<DatePickerLabels> | Texts of the component. Pass only the ones you want to change, for example to translate it. |
| color | string | Accent color of this component: any CSS color. Without it the component uses `--blossom-accent`, which is pink by default. |
| value | Date | null | |
| defaultValue | Date | null | |
| onChange | (date: Date) => void | |
| label | string | |
| placeholder | string | |
| min | Date | Dates before this one cannot be chosen. |
| max | Date | Dates after this one cannot be chosen. |
| locale | string | Locale used for the month names and the displayed date. |
| disabled | boolean |
DateRange
| Prop | Type | Description |
|---|---|---|
| start (required) | Date | null | |
| end (required) | Date | null |
DateRangePickerProps
| Prop | Type | Description |
|---|---|---|
| required | boolean | Marks the field as required: an asterisk is shown next to the label. |
| hint | string | Helper text shown under the field. |
| error | string | Error message. It is shown in red under the field and marks it as invalid. |
| labels | Partial<DatePickerLabels> | Texts of the component. Pass only the ones you want to change, for example to translate it. |
| color | string | Accent color of this component: any CSS color. Without it the component uses `--blossom-accent`, which is pink by default. |
| value | DateRange | |
| defaultValue | DateRange | |
| onChange | (range: { start: Date; end: Date }) => void | Called once both days are chosen. |
| label | string | |
| placeholder | string | |
| min | Date | Dates before this one cannot be chosen. |
| max | Date | Dates after this one cannot be chosen. |
| locale | string | Locale used for the month names and the displayed dates. |
| disabled | boolean |