Date PickerReady

Date Picker allows user to enter a date either through text input, or by choosing a date from the calendar. Please note that the date must be passed in ISO-8601 format: YYYY-MM-DD.

Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
Edit in CodePen
Open in new window
View RTL
<nord-date-picker label="Label" value="2021-01-13"></nord-date-picker>

Properties

PropertyAttributeDescriptionTypeDefault
valuevalue

Date value. Must be in IS0-8601 format: YYYY-MM-DD.

string""
valueAsDate

Get/set the value of the picker as a Date object.

Date | undefinedundefined
valueAsNumber

Get/set the value of the picker as the number of milliseconds elapsed since the UNIX epoch.

numberundefined
rawValue

Get the raw value of the input field without date formatting. This is a read-only property.

string | undefinedundefined
openopen

Controls whether date picker dialog is open or not.

booleanfalse
minmin

Minimum date allowed to be picked. Must be in IS0-8601 format: YYYY-MM-DD. This setting can be used alone or together with the max property.

string | undefinedundefined
maxmax

Maximum date allowed to be picked. Must be in IS0-8601 format: YYYY-MM-DD. This setting can be used alone or together with the min property.

string | undefinedundefined
firstDayOfWeekfirst-day-of-week

Which day is considered first day of the week? 0 for Sunday, 1 for Monday, etc. Default is Monday.

DaysOfWeekundefined
dateAdapter

Date adapter, for custom parsing/formatting. Must be object with a parse function which accepts a string and returns a Date, and a format function which accepts a Date and returns a string. Default is IS0-8601 parsing and formatting.

DateAdapterisoAdapter
isDateDisabled

Controls which days are disabled and therefore disallowed. For example, this can be used to disallow selection of weekends.

DatePredicateisDateDisabled
isDateHighlighted

Controls which days are highlighted with a small indicator. Returning false will not show an indicator. Returning true will show the indicator, but without an accessible label. Therefore Returning a string will show the indicator, and use the string as accessible label. It is recommended to return a string rather than true whenever possible.

(date: Date) => string | booleanisDateHighlighted
expandexpand

Controls whether the date picker expands to fill the width of its container.

booleanfalse
sizesize

The size of the component.

"s" | "m" | "l""m"
labellabel

Label for the input.

string""
hinthint

Optional hint text to be displayed with the input. Alternatively use the hint slot.

string | undefinedundefined
hideLabelhide-label

Visually hide the label, but still show it to assistive technologies like screen readers.

booleanfalse
placeholderplaceholder

Placeholder text to display within the input.

string | undefinedundefined
errorerror

Optional error to be shown with the input. Alternatively use the error slot.

string | undefinedundefined
requiredrequired

Determines whether the input is required or not. An input marked as required will be announced as such to users of assistive technology. When using this property you need to also set “novalidate” attribute on a form element to prevent browser from displaying its own validation errors.

booleanfalse
hideRequiredhide-required

Visually hide the required indicator, but still show required attribute to assistive technologies like screen readers.

booleanfalse
readonlyreadonly

Makes the component readonly, so that it is not editable. Readonly differs from disabled in that readonly fields are still focusable and will be submitted with a form.

booleanfalse
disableddisabled

Makes the component disabled. This prevents users from being able to interact with the component, and conveys its inactive state to assistive technologies.

booleanfalse
namename

The name of the form component.

string | undefinedundefined
formform

Gets the form, if any, associated with the form element. The setter accepts a string, which is the id of the form.

HTMLFormElement | nullundefined

Events

EventDescriptionType
change

Fired whenever the input's value is changed via user interaction.

NordEvent
open

Dispatched when the popout is opened.

NordEvent
close

Dispatched when the popout is closed.

NordEvent
nord-focus-date

Dispatched when the calendar's focused date changes.

DateSelectEvent
input

Fired as the user types into the input.

NordEvent

Methods

Method nameParametersDescription
hide(moveFocusToButton?: boolean) => voidmoveFocusToButton: A boolean option to move the focus to the original button that opens the popout.

Hide the date picker programmatically.

show() => voidN/A

Show the date picker programmatically.

focus(options?: FocusOptions) => voidoptions: An object which controls aspects of the focusing process.

Programmatically move focus to the component.

blur() => voidN/A

Programmatically remove focus from the component.

click() => voidN/A

Programmatically simulates a click on the component.

CSS Properties

CSS Custom Properties provide more fine grain control over component presentation. We advise utilizing existing properties on the component before using these.

PropertyDescriptionDefault
--n-label-color

Controls the text color of the label, using our color tokens.

var(--n-color-text)

Localization

This component requires localization in a multi-lingual application. The following keys are required when registering a translation:

KeyDescription
modalHeading

Heading for the date picker's modal.

closeLabel

Accessible label for the close button.

buttonLabel

Accessible label for the toggle button that opens the date picker modal.

selectedDateMessage

Describes the selected date. This message is appended to the toggle button label when a date is selected.

For full localization guidelines, please see Localization documentation.

Localization Guidelines


Dependencies

This component is internally dependent on the following components:


Usage

This section includes guidelines for designers and developers about the usage of this component in different contexts.

Do

  • Use when the user needs to choose a single date or a date range.

Don’t

  • Don’t use for entering date of birth. Use input component instead.
  • Don’t use to choose a date that is over 10 years in the future or the past.

Keyboard accessibility

Date picker is built to closely follow W3C Date Picker Dialog example with some small exceptions to e.g. better support iOS VoiceOver and Android TalkBack.

Choose date button

  • Space, Enter: Opens the date picker dialog and moves focus to the first select menu in the dialog.

Date picker dialog

  • Esc: Closes the date picker dialog and moves focus back to the “choose date” button.
  • Tab: Moves focus to the next element in the dialog. Please note since the calendar uses role="grid", only one button in the calendar grid is in the tab sequence. Additionally, if focus is on the last focusable element, focus is next moved back to the first focusable element inside the date picker dialog.
  • Shift + Tab: Same as above, but in reverse order.

Date picker dialog: Month/year buttons

  • Space, Enter: Changes the month and/or year displayed.

Date picker dialog: Date grid

  • Space, Enter: Selects a date, closes the dialog, and moves focus back to the “Choose Date” button. Additionally updates the value of the date picker input with the selected date, and adds selected date to “Choose Date” button label.
  • Arrow up: Moves focus to the same day of the previous week.
  • Arrow down: Moves focus to the same day of the next week.
  • Arrow right: Moves focus to the next day. In right-to-left languages, moves focus to the previous day.
  • Arrow left: Moves focus to the previous day. In right-to-left languages, moves focus to the next day.
  • Home: Moves focus to the first day (e.g Monday) of the current week.
  • End: Moves focus to the last day (e.g. Sunday) of the current week.
  • Page Up: Changes the grid of dates to the previous month and sets focus on the same day of the same week.
  • Shift + Page Up: Changes the grid of dates to the previous year and sets focus on the same day of the same week.
  • Page Down: Changes the grid of dates to the next month and sets focus on the same day of the same week.
  • Shift + Page Down: Changes the grid of dates to the next year and sets focus on the same day of the same week.

Date picker dialog: Close button

  • Space, Enter: Closes the dialog, moves focus to “choose date” button, but does not update the date in input.

Integration

For integration guidelines, please see Web Components documentation. This documentation explains how to implement and use Nord Web Components across different technologies such as Vue.js, React, or Vanilla JavaScript.

Integration Guidelines

Troubleshooting

If you experience any issues while using Nord Web Components, please head over to the Support page for more guidelines and ways to contact us.


Was this page helpful?

YesNo
Send feedback

We use this feedback to improve our documentation.