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.
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>
Range DatePicker
Code Editor
<DatePicker label="DatePicker:" start_date="2019-04-01" end_date="2019-05-17" range={true} show_input={true} on_change={({ start_date, end_date }) => { console.log('on_change', start_date, end_date) }} on_submit={({ start_date, end_date }) => { console.log('on_submit', start_date, end_date) }} on_cancel={({ start_date, end_date }) => { console.log('on_cancel', start_date, end_date) }} shortcuts={[ { title: 'Set date period', start_date: '1969-07-15', end_date: '1969-08-15', }, { title: 'Today', start_date: new Date(), }, { title: 'This week', start_date: startOfWeek(new Date()), end_date: lastDayOfWeek(new Date()), }, { close_on_select: true, title: 'This month', start_date: startOfMonth(new Date()), end_date: lastDayOfMonth(new Date()), }, { title: 'Relative +3 days', start_date: ({ start_date }) => start_date || new Date(), end_date: ({ end_date }) => addDays(end_date || new Date(), 3), }, ]} />