Props
Usage guidelines
- Allowing users to choose a date or date range by clicking through the calendar popup or typing in the text field.
- Limiting date options to a specific range of dates.
- When the native date picking experience is preferred (typically mobile and mWeb experiences). In this case, use TextField with type=”date”.
Example: Basic Date Picker
Use DatePicker to select date inputs.
Example: Preselected Date
Provide pre-selected date values to DatePicker.
Example: Date Range Picker
Use DatePicker to select date range inputs.
Example: Disabled
Example: Delimited selection period
Disable dates outside of a min and max date range.
Example: Enabled dates
Enable an array of dates.
Example: Disabled dates
Disable an array of dates.
Example: Helper Text
Display a helper message for cases where you want to provide more information about the date field.
Example: Error Message
Display an error message. Error message overrides the helper text.
Example: Ideal Direction
Define the preferred direction for the DatePicker popover to open. If that placement doesn't fit, the opposite direction will be used.
Example: Locales
Adjust the date format to each date-fns locale (https://date-fns.org/v2.14.0/docs/Locale).
The following locale examples show the different locale format variants.
IMPORTANT: Locale data from date-fns is external to gestalt-datepicker, it's not an internal dependency. Add date-fns to your app's dependencies.
import DatePicker from 'gestalt-datepicker';
import { it } from 'date-fns/locale';
<DatePicker localeData={it}/>