Import
import { DatePicker } from '@dnb/eufemia'
Description
The DatePicker component should be used whenever there is to enter a single date or a date range/period with a start and end date.
Date Object
The DatePicker operates with a default JavaScript Date instance as well as string (ISO 8601) like start_date="2019-05-05"
(yyyy-MM-dd).
For more DatePicker examples, have a look at this CodeSandbox.
minDate
, maxDate
and invalid dates
Validation for Field.Date
has built in valdation for minDate
, maxDate
and invalid dates.
This is the preffered method of handling scenarios where the user has typed in an invalid date, or a date outside of the set date limits.
Automatically changing the user input on the other hand, leads to worse UX, and confusion, as the user might not understand why the date is changed, for seemingly no reason.
So it's best practice to actually tell the user what is wrong, and let them correct it.
Demos
English (US) is not included in Eufemia by default. You can include it like:
import enUS from '@dnb/eufemia/shared/locales/en-US'<EufemiaProvider locale={enUS} ...>App</EufemiaProvider>