FormikDatePicker
Basic Usage
import { FormikDatePicker } from '@krakentech/coral-formik';
import { Button } from '@krakentech/coral';
import { Formik, Form } from 'formik';
<Formik
initialValues={{ datepicker: '' }}
onSubmit={() => console.log('Submitted')}
validationSchema={yup.object().shape({
datepicker: yup.string().required('This field is required'),
})}
>
<Form method="post">
<FormikDatePicker name="datepicker" label="Select date" />
<Button type="submit">Submit</Button>
</Form>
</Formik>Full API
| Name | Type | Default |
|---|---|---|
disabled | booleanIf | false |
disableFuture | booleanIf | false |
disablePast | booleanIf | false |
defaultMonth | DateThe default month to display when the DatePicker is opened. | |
endIcon | ReactNodeThe icon displayed at the end of the DatePicker input. | |
excludeDateIntervals | { start: Date; end: Date; }[]A list of date intervals to exclude from selection. Each interval is defined by a start and end date. | [] |
excludeDates | Date[]A list of dates to exclude from selection. | [] |
fullWidth | ResponsiveVariant<boolean>If | |
id | stringThe id of the input element. If unspecified, an id will be generated internally. | |
includeDateIntervals | { start: Date; end: Date; }[]A list of date intervals to include from selection. Each interval is defined by a start and end date. | [] |
includeDates | Date[]A list of dates to include from selection. | [] |
isClearable | booleanIf | false |
label | stringThe label for the DatePicker input field. | |
locale | SupportedLocaleThe locale to use for formatting dates. | en-GB |
maxDate | Date | nullThe maximum date allowed for selection. | |
minDate | Date | nullThe minimum date allowed for selection. | |
name | stringThe field name used on the POST request when the form is submitted. | |
nextMonthButtonLabel | stringThe aria-label for the DatePicker’s next month button. | 'Next month' |
nextYearButtonLabel | stringThe aria-label for the DatePicker’s next year button. | 'Next year' |
numberOfMonths | numberThe number of months to display in the DatePicker. | |
onBlur | FocusEventHandler<HTMLInputElement>Callback fired when the input loses user focus.
| |
onCalendarClose | () => voidCallback fired when the calendar popup is closed. | |
onCalendarOpen | () => voidCallback fired when the calendar popup is opened. | |
onChange | (date: Date | DateRange | null) => voidCallback fired when the selected date changes.
| |
onClickOutside | (event: Event | undefined) => voidCallback fired when the user clicks outside the DatePicker.
| |
onFocus | (event: Event | undefined) => voidCallback fired when the DatePicker input gains user focus.
| |
onInputClick | () => voidCallback fired when the DatePicker input is clicked. | |
onKeyDown | (event: KeyboardEvent<HTMLDivElement>) => voidCallback fired when a key is pressed down on the DatePicker input. | |
onMonthChange | (date: Date) => voidCallback fired when the month is changed.
| |
onSelect | (date: Date, event: Event | undefined) => voidCallback fired when a date is selected.
| |
open | booleanIf | |
theme | ResponsiveVariant<SharedThemeTypes>The colourway applied to this component. | 'base100' |
placeholderText | stringThe placeholder text for the input field. | |
popperPlacement | PlacementPosition of the popper relative to the input. | |
previousMonthButtonLabel | stringThe aria-label for the DatePicker’s previous month button. | 'Previous month' |
previousYearButtonLabel | stringThe aria-label for the DatePicker’s previous year button. | 'Previous year' |
optional | booleanAdd an optional flag to the label for this field (controlled by https://coral-oe.vercel.app/?path=/docs/guides-configuration—docs#overrides-optional-indicator optionalIndicator). This should be set to true if you have set this field to be optional in your validation schema. | false |
selectsRange | booleanIf | false |
shouldCloseOnSelect | booleanIf | true |
showYearPicker | booleanIf | false |
showYearDropdown | booleanIf | false |
startIcon | ReactNodeThe icon displayed at the start of the DatePicker input field. | |
tabIndex | numberThe tab index for the DatePicker input. | |
title | stringThe label title for the DatePicker input. | |
yearDropdownItemNumber | numberThe number of items which are displayed in the year dropdown in each direction. | 100 |
upLevelButtonLabel | stringThe aria-label for the button that moves back to calendar view from Month or Year view. | 'Back to Calendar' |
monthSelectionLabel | stringThe aria-label for the manual month selection. | 'Select Month' |
yearSelectionLabel | stringThe aria-label for the manual year selection. | 'Select Year' |
datesTableLabel | ReactNode | |
monthsTableLabel | ReactNode | |
yearsTableLabel | ReactNode | |
validate | FieldValidator | undefinedAn optional field level validation function. See Formik docs for more details |