Hero Image

Components

Date Picker

The Date Picker comes with multiple options: time, range and as a simple calendar

<No Display Name onSet={function noRefCheck() {}} />

The Date Picker is an extension of the react-calendar , and the props available for the react-calendar are possible to pass in to the Date Picker.

Properties

DatePicker

Prop nameTypeDefault ValueDescription
brandingunion'neutral'Custom branding. Built in support for neutral, sport and tur.
hasButtonsboolfalseIf false, the calendar will close and run onSet Function on date selection. If true, the calendar will stay open and run onSet Function on submit. If calendar has time, the calendar will always have submit button and onSet function is called onSubmit. If calendar has range, the calendar will always have submit button and onSet function is called onSubmit.
hasDisabledFormTagboolfalseDisable the wrapping form tag. If you use this prop you need to wrap the DatePicker in a svs Form tag.
hasErrorboolfalseIf component has an error state.
hasRangeboolfalseIf calendar has range selection.
hasTimeboolfalseIf calendar has time selection. If calendar has range and time, two time pickers will be rendered. One for start time and one for end time.
isDisabledboolfalseDisables the input. Default is false.
isOpenboolfalseControls the visibility of the calendar.
minDateinstanceOfnew Date(2019, 0, 1)Sets the minimum date that the calendar will display. Default to 1/1 2019.
onOpen() => {}
openWithButtonboolfalseIf the calendar should open with a button. Default is false.
popupPositionunion''If set calendar should appear on top of other elements. And is aligned to the left, center or right.
classNamestringCustom classes.
enabledDatesArrayarrayArray with dates objects that should be the only available dates to pick. Should be in yyyy-mm-dd format.
errorMessagestringCustomized error message.
externalInputValuestringCustom external input value.
helpMessagestringCustomized help message for input.
infoMessagestringCustomized info message.
initialDateinstanceOfInitial date for the calendar. Defaults no date if not set.
initialEndTimestringInitial ending time for the calendar. Defaults to 00:00.
initialStartTimestringInitial startting time for the calendar. Defaults to 00:00.
inputHelpTextstringHelp text for input label.
inputIdstringCustom id for the DateInput.
inputLabelstringCustom label for the input field. Defaults to either 'Välj period' if the datePicker has a range or 'Välj dag' if its a singular input.
inputNamestringCustom name for the DateInput. Default dateInput.
onBlurfunconBlur function for the input.
onSet *funcCallback function when date is set, returns array with date objects. One date object if calendar has no range. Two date objects if calendar has range.
topComponentelementCustom component to render above the calendar. If custom component needs to handle isOpen prop, pass a function to onOpen prop to be able to control the calendar.

Accessibility

This component has been validated to meet the WCAG 2.1 AA accessibility guidelines.

Read more about WCAG 2.1 AA.