DateRangePicker New Alpha Light DOM & Tailwind

Open in Storybook

Lets users choose a start and end date as a single range, from a list of presets or a range calendar.

OverviewUsageStandalone or inside a FieldExamplesAccessibilityAPI referenceDependencies
This component is considered alpha. We're still finalising the API, so it may include a breaking change at any time — use it at your own risk.
Loading...

Usage

Date Range Picker lets people choose a start and end date as a single range. They can pick a built-in preset (Today, Last 7 days, This month, …) or drag out a range across the calendar, which shows two months side by side on wider screens and a single month on narrow ones. Reach for it for reporting periods, filters and any "from–to" date input.

The date range picker renders its built-in label, hint and error on its own. Wrapped in a Field, the Field takes over with a Field Label, Field Description and Field Error, and the built-in versions step aside automatically.

Copy code
import "@nordhealth/components/lib/DateRangePicker"
import "@nordhealth/components/lib/Field"
import "@nordhealth/components/lib/FieldLabel"
import "@nordhealth/components/lib/FieldDescription"
import "@nordhealth/components/lib/FieldError"

The committed value is an ISO-8601 interval string YYYY-MM-DD/YYYY-MM-DD. The convenience start-date / end-date properties and the valueAsDateRange getter/setter stay in sync with it.

Selecting in the popout builds a pending range. Apply commits it (firing a change event), Cancel reverts to the last committed value, and Clear empties the selection.

Standalone or inside a Field

Use the control on its own with its built-in label, hint and error, or wrap it in a Field — the Field then provides the labelling. Both render the same control:

InlineWith Field

Examples

Presets

A built-in list of presets is shown by default. Add hide-presets to suppress it and show only the calendar.

Error

Show validation with a Field Error and mark the Field invalid.

Required

Mark a field as required by setting required on the Field Label.

Two-field form submission

By default the picker submits the interval string under its name. Set both start-name and end-name to instead submit the start and end as two separate form fields.

Min and max

Constrain the selectable dates with min and max (both ISO YYYY-MM-DD). Dates outside the range are disallowed in the calendar, and a committed range that falls outside the bounds sets a validation error.

Inline

Set inline to render the presets, calendar and actions directly on the page, with no trigger button or popout. Useful when the picker lives in a form rather than behind a trigger.

Custom trigger

Provide your own trigger element with slot="trigger" and it replaces the built-in button while keeping all the popout behaviour. This is how you compose the picker into a Filter Bar — drop a filter chip in as the trigger. The picker wires aria-haspopup, aria-controls and aria-expanded onto whatever you provide.

Disabled

Add disabled to prevent interaction while still showing the committed value.

Invalid

Mark the Field invalid and pair it with a Field Error to convey a validation problem.

Sizes

The size attribute accepts s, m (default) and l.

RTL

Date Range Picker follows the document or container direction. Toggle the direction to see the layout mirror.

Accessibility

  • Give the date range picker an accessible name with its built-in label, or — inside a Field — a Field Label connected via for.
  • Convey validation with a Field Error rather than colour alone — it is associated with the control and announced to assistive technology.
  • Mark required fields by setting required on the Field Label; it shows the indicator and marks the control required.
  • The trigger is a button that opens a dialog popout; it exposes aria-haspopup, aria-expanded and aria-controls so assistive tech announces its state.
  • The range calendar is fully keyboard navigable: move with the arrow keys, jump months with Page Up / Page Down, and pick the start and end with Enter or Space.
  • The preset list, calendar and Apply / Cancel / Clear actions are all reachable and labelled, and every label is localizable.

API reference

DateRangePicker

Date Range Picker lets people choose a start and end date as a single range, either from a built-in list of presets (Today, Last 7 days, This month, …) or from a range calendar. It is a control only — compose it inside a Field for a label, hint or error, like a native input. The committed value is an ISO-8601 interval string YYYY-MM-DD/YYYY-MM-DD; the convenience start-date / end-date props and the valueAsDateRange getter/setter stay in sync with it. Selecting in the popout builds a *pending* range; **Apply** commits it (firing change), **Cancel** reverts to the last committed value, and **Clear** empties it.

<nord-date-range-picker></nord-date-range-picker>

Props

PropertyAttribute Description TypeDefault
valuevalueThe committed value as an ISO-8601 interval string YYYY-MM-DD/YYYY-MM-DD. An empty string means no range is committed.string''
startDatestart-dateConvenience accessor for the committed start date, in ISO-8601 format. Kept in sync with value and end-date.string''
endDateend-dateConvenience accessor for the committed end date, in ISO-8601 format. Kept in sync with value and start-date.string''
openopenControls whether the popout is open.booleanfalse
minminMinimum date allowed to be picked, in ISO-8601 format: YYYY-MM-DD.string | undefined
maxmaxMaximum date allowed to be picked, in ISO-8601 format: YYYY-MM-DD.string | undefined
todaytodayThe date that is considered today, in ISO-8601 format. Presets resolve relative to this; if unset, the user's current local date is used.string | undefined
firstDayOfWeekfirst-day-of-weekWhich day is considered the first day of the week. 0 for Sunday, 1 for Monday, etc. Default is Monday.DaysOfWeek
hidePresetshide-presetsHides the built-in list of preset ranges, leaving only the calendar.booleanfalse
inlineinlineRender the picker inline — the presets, calendar and Apply/Cancel/Clear are always visible, with no trigger button or popout. Use it when the picker lives directly on the page (e.g. in a form) rather than behind a trigger.booleanfalse
startNamestart-nameThe name used to submit the **start** date as its own form field. When both start-name and end-name are set, the picker submits two fields (start-name=startDate, end-name=endDate) instead of the single name.string | undefined
endNameend-nameThe name used to submit the **end** date as its own form field. See start-name.string | undefined
sizesizeThe size of the component.'s' | 'm' | 'l''m'
placeholderplaceholderPlaceholder text to display within the control.string | undefined
requiredrequiredDetermines whether the control is required or not. A required control is announced as such to assistive technology and, inside a <nord-field>, drives the required indicator on the <nord-field-label>. 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
readonlyreadonlyMakes 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
disableddisabledMakes the component disabled. This prevents users from being able to interact with the component, and conveys its inactive state to assistive technologies.booleanfalse
namenameThe name of the form component.string | undefined
formformGets the form, if any, associated with the form element. The setter accepts a string, which is the id of the form.HTMLFormElement | null

Field properties

PropertyAttribute Description TypeDefault
labellabelLabel for the control. Ignored when the control is wrapped in a <nord-field>, which provides the label via <nord-field-label>.string''
hinthintOptional hint text shown with the control. Ignored inside a <nord-field>, which provides it via <nord-field-description>.string | undefined
hintBelowhint-belowRenders the hint below the control and any error instead of below the label.booleanfalse
hideLabelhide-labelVisually hide the label, but still expose it to assistive technologies.booleanfalse
errorerrorOptional error shown with the control. Ignored inside a <nord-field>, which provides it via <nord-field-error>.string | undefined
hideRequiredhide-requiredVisually hide the required indicator, but still expose the required state to assistive technologies.booleanfalse

Slots

Slot name Description
triggerOptional custom trigger element (e.g. a filter chip or a nord-button) that opens the picker. Replaces the built-in trigger button when provided.

Methods

Method nameParameters Description
show() => voidN/AOpen the picker programmatically.
hide(moveFocusToToggle: unknown) => voidmoveFocusToToggle: Move focus back to the trigger after closing.Close the picker programmatically.
focus(options?: FocusOptions) => voidoptions: FocusOptionsMove focus to the picker's trigger.
blur() => voidN/AProgrammatically remove focus from the component.
click() => voidN/AProgrammatically simulates a click on the component.
EventDetail TypeDescription
inputNordEventDispatched live as the pending range changes inside the popout.
changeNordEventDispatched when the committed range changes (Apply or Clear).
openNordEventDispatched when the popout is opened.
closeNordEventDispatched when the popout is closed.

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-date-range-picker-trigger-min-inline-sizeControls the minimum inline size of the trigger.14rem
--n-date-range-picker-popout-inline-sizeControls the inline size of the popout content.
Light DOM & Tailwind. This component renders in the light DOM, so you can style it directly with your own CSS or Tailwind utility classes — there is no shadow boundary, and its default styles are low specificity, so your utilities win.

Was this page helpful?

Yes No

We use this feedback to improve our documentation.