Properties
Property | Type | Description |
---|---|---|
date | string Date | (optional) Defines the pre-filled date by either a JavaScript DateInstance or (ISO 8601) like date="2019-05-05" and content . |
startDate | string Date | (optional) To set the pre-filled starting date. Is used if range={true} is set to true . Defaults to null , showing the maskPlaceholder . |
endDate | string Date | (optional) To set the pre-filled ending date. Is used if range={true} is set to true . Defaults to null , showing the maskPlaceholder |
month | string Date | (optional) To display what month should be shown in the first calendar by default. Defaults to the date respective startDate . |
startMonth | string Date | (optional) To display what month should be shown in the first calendar by default. Defaults to the date respective startDate . |
endMonth | string Date | (optional) To display what month should be shown in the second calendar by default. Defaults to the date respective startDate . |
minDate | string Date | (optional) To limit a date range to a minimum startDate . Defaults to null . |
maxDate | string Date | (optional) To limit a date range to a maximum endDate . Defaults to null . |
dateFormat | string | (optional) Defines how the property dates (date , startDate and endDate ) should be parsed, e.g. yyyy/MM/dd . Defaults to yyyy-MM-dd . |
returnFormat | string | (optional) Defines how the returned date, as a string, should be formatted as. Defaults to yyyy-MM-dd . |
range | boolean | (optional) Defines if the Date field should support a value of two dates (starting and ending date). The value needs to be a string containing two dates, separated by a pipe character (| ) (01-09-2024|30-09-2024 ) when this is set to true . Defaults to false . |
showInput | boolean | (optional) If the input fields with the mask should be visible. Defaults to false . |
maskOrder | string | (optional) To define the order of the masked placeholder input fields. Defaults to dd/mm/yyyy . |
opened | boolean | (optional) To open the date-picker by default. Defaults to false . |
maskPlaceholder | string | (optional) To display the placeholder on input. Defaults to dd/mm/åååå . |
hideNavigation | boolean | (optional) If set to true , the navigation will be hidden. Defaults to false . |
hideDays | boolean | (optional) If set to true , the week days will be hidden. Defaults to false . |
showSubmitButton | boolean | (optional) If set to true , a submit button will be shown. You can change the default text by using submitButtonText="Ok" . Defaults to false . If the range property is true , then the submit button is shown. |
showCancelButton | boolean | (optional) If set to true , a cancel button will be shown. You can change the default text by using cancelButtonText="Avbryt" . If the range property is true , then the cancel button is shown. Defaults to false |
showResetButton | boolean | (optional) If set to true , a reset button will be shown. You can change the default text by using resetButtonText="Tilbakestill" . Defaults to false . |
link | boolean | (optional) Link both calendars, once to the user is navigating between months. Only meant to use if the range is set to true . Defaults to false . |
sync | boolean | (optional) Sync input values with the calendars views. Once the input values get changed, the calendar changes its views in sync. Defaults to true . |
firstDay | monday tuesday wednesday thursday friday saturday sunday | (optional) To define the first day of the week. Defaults to monday . |
alignPicker | string | (optional) Use right to change the calendar alignment direction. Defaults to left . |
onlyMonth | boolean | (optional) Use true to only show the defined month. Disables the month navigation possibility. Defaults to false . |
hideLastWeek | boolean | (optional) Use true to only show the last week in the current month if it needs to be shown. The result is that there will mainly be shows five (5) weeks (rows) instead of six (6). Defaults to false . |
stretch | boolean | (optional) If set to true , then the date-picker input field will be 100% in width |
label | React.ReactNode | (optional) A prepending label in sync with the date input field. |
labelDirection | vertical horizontal | (optional) Use label_direction="vertical" to change the label layout direction. Defaults to horizontal . |
suffix | React.ReactNode | (optional) Text describing the content of the DatePicker more than the label. You can also send in a React component, so it gets wrapped inside the DatePicker component. |
labelSrOnly | boolean | (optional) Use true to make the label only readable by screen readers. |
shortcuts | object | (optional) Gives you the possibility to set predefined dates and date ranges so the user can select these by one click. Define either a JSON or an object with the defined shortcuts. More info is below. |
addonElement | object | (optional) Gives you the possibility to inject a React element showing up over the footer. Use it to customize shortcuts . |
inputElement | React.ReactNode | (optional) Gives you the possibility to use a plain/vanilla <input /> HTML element by defining it as a string inputElement="input" , a React element, or a render function inputElement={(internalProps) => (<Return />)} . Can also be used in circumstances where the react-text-mask should not be used, e.g. in testing environments. Defaults to custom masked input. |
status | string | boolean | (optional) Text with a status message. The style defaults to an error message. You can use true to only get the status color, without a message. |
statusState | string | (optional) Defines the state of the status. Currently, there are two statuses [error, info] . Defaults to error . |
statusProps | object | (optional) Use an object to define additional FormStatus properties. |
disableAutofocus | boolean | (optional) Once the date picker gets opened, there is a focus handling to ensure good accessibility. This can be disabled with this property. Defaults to false . |
correctInvalidDate | boolean | (optional) Corrects the input date value to be the same as either minDate or maxDate , when the user types in a date that is either before or after one of these. Defaults to false . |
globalStatus | object | (optional) The configuration used for the target GlobalStatus. |
tooltip | string | (optional) Provide a short Tooltip content that shows up on the picker button. |
skeleton | boolean | (optional) If set to true , an overlaying skeleton with animation will be shown. |
size | string | (optional) The sizes you can choose is small (1.5rem), default (2rem), medium (2.5rem) and large (3rem) are supported component sizes. Defaults to default / null . |
Space | string object | (optional) Spacing properties like top or bottom are supported. |
Translations
More info about translations can be found in the general localization and Eufemia Forms localization docs.
Key | nb-NO | en-GB | en-US |
---|---|---|---|
DatePicker.day | dag | Day | Day |
DatePicker.month | måned | Month | Month |
DatePicker.year | år | Year | Year |
DatePicker.start | fra | from | from |
DatePicker.end | til | to | to |
DatePicker.selectedDate | Valgt dato: %s | Selected date: %s | Selected date: %s |
DatePicker.selectedMonth | Valgt måned %s | Selected month %s | Selected month %s |
DatePicker.selectedYear | Valgt år %s | Selected year %s | Selected year %s |
DatePicker.nextMonth | Neste måned %s | Next month %s | Next month %s |
DatePicker.prevMonth | Forrige måned %s | Previous month %s | Previous month %s |
DatePicker.nextYear | Neste år %s | Next year %s | Next year %s |
DatePicker.prevYear | Forrige år %s | Previous year %s | Previous year %s |
DatePicker.openPickerText | åpne datovelger | Open date picker | Open date picker |
DatePicker.maskOrder | dd/mm/yyyy | dd/mm/yyyy | mm/dd/yyyy |
DatePicker.maskPlaceholder | dd.mm.åååå | dd/mm/yyyy | mm/dd/yyyy |
DatePicker.dateFormat | yyyy-MM-dd | yyyy-MM-dd | yyyy-MM-dd |
DatePicker.returnFormat | yyyy-MM-dd | yyyy-MM-dd | yyyy-MM-dd |
DatePicker.submitButtonText | Ok | OK | OK |
DatePicker.cancelButtonText | Avbryt | Cancel | Cancel |
DatePicker.resetButtonText | Tilbakestill | Reset | Reset |
DatePicker.placeholderCharacters.day | d | d | d |
DatePicker.placeholderCharacters.month | m | m | m |
DatePicker.placeholderCharacters.year | å | y | y |
DatePicker.firstDay | sunday |
Shortcuts
You may use date-fns to make date calculations.
Code Editor
<DatePicker shortcuts={[ { title: 'Set date', date: '1969-07-15', }, { title: 'Relative +3 days', date: ({ date }) => date && addDays(date, 3), }, ]} />
With range enabled.
Code Editor
<DatePicker shortcuts={[ { title: 'Set date period', start_date: '1969-07-15', end_date: '1969-07-15', close_on_select: true, // will close the picker }, { title: 'This month', start_date: startOfMonth(new Date()), end_date: lastDayOfMonth(new Date()), }, ]} />