Skip to content

Date range picker ​

One field for the start and end dates of a period.

The model holds the period as a { start, end } object, with each date a YYYY-MM-DD string or null.

Installation ​

ts
import { NuiDateRangePicker } from '@numior/kit';

Usage ​

Pick a period and change the number of months, the size and the states of the field.

How many months the calendar shows side by side.

Where the calendar opens, such as bottom-start or top.

size
Changes the size of the control: sm, md or lg. The theme density shifts the height of each size.

Label of the control. Inside NuiField the field provides the label.

Error text below the control. Puts the control into the error state.

Behavior ​

  • Both dates are typed the same way as in a Date picker.
  • When the end comes before the start, the field swaps them once the focus leaves the date.
  • In the calendar the first click picks the start, and the second picks the end and closes the calendar.
  • The clear button from clearable resets both dates.

Accessibility ​

The label text names the start date, and a screen reader announces the end date as "End date". Change that text in endLabel. The hint and the error are read out for both dates.

Keys
Action
↓
Opens the calendar. When it is open, moves the focus into it.
Esc
Closes the calendar.

API ​

Props

Name
Type
Default
Description
startPlaceholder
string
—
Text shown in the empty start date field.
endPlaceholder
string
—
Text shown in the empty end date field.
startName
string
—
The name of a hidden input that sends the start date with the form.
endName
string
—
The name of a hidden input that sends the end date with the form.
endLabel
string
—
End date field label for screen readers. Defaults to "End date" from the dictionary.
presets
readonly NuiDatePreset[]
—
Ready-made periods next to the calendar, such as "Last 7 days".
locale
string
—
Language, date format and first day of the week. Defaults to createNuiConfig.
weekStart
Weekday
—
First day of the week, from 1 (Monday) to 7 (Sunday). Defaults to the locale.
min
string
—
Earliest date that can be selected, January 1, 100 by default.
max
string
—
Latest date that can be selected, December 31, 9999 by default.
isDateDisabled
((date: string) => boolean)
—
Function that disables individual dates, such as weekends.
weekNumbers
boolean
false
Shows a week number column in the calendar.
months
number
2
How many months the calendar shows side by side.
today
string
—
Today as YYYY-MM-DD. Without it the browser clock gives the date after mounting.
clearable
boolean
false
Shows a button in the field that clears the date.
openOnClick
boolean
false
Opens the calendar on a click in the field. The focus stays there, so the date can still be typed.
placement
Placement
"bottom-start"
Where the calendar opens, such as bottom-start or top.
openLabel
string
—
Calendar button label for screen readers. Defaults to "Choose date" from the dictionary.
clearLabel
string
—
Clear button label for screen readers. Defaults to "Clear" from the dictionary.
dialogLabel
string
—
Calendar popover label for screen readers. Defaults to "Calendar" from the dictionary.
todayLabel
string
—
Text of the "Today" button. Defaults to "Today" from the dictionary.
previousLabel
string
—
Previous month button label for screen readers. Defaults to "Previous month" from the dictionary.
nextLabel
string
—
Next month button label for screen readers. Defaults to "Next month" from the dictionary.
monthLabel
string
—
Month picker button label for screen readers. Defaults to "Choose month" from the dictionary.
yearLabel
string
—
Year picker button label for screen readers. Defaults to "Choose year" from the dictionary.
weekLabel
string
—
Week number column heading for screen readers. Defaults to "Week" from the dictionary.
id
string
—
Id of the control. Defaults to the one from NuiField or is generated automatically.
size
NuiSize
"md"
Changes the size of the control: sm, md or lg. The theme density shifts the height of each size.
disabled
boolean
—
Disables the control. Inside NuiField it defaults to the field value.
readonly
boolean
—
Shows the date without letting it change: typing and the calendar are blocked.
required
boolean
—
Marks the control as required. Inside NuiField it defaults to the field value.
invalid
boolean
—
Shows the error state without a text. With error it turns on by itself.
label
string
—
Label of the control. Inside NuiField the field provides the label.
description
string
—
Hint below the control. Screen readers announce it with the control.
error
string
—
Error text below the control. Puts the control into the error state.
reserveError
boolean
false
Reserves space for the error so the form does not shift when it appears.

Models

Name
Type
Default
Description
v-model
DateRange
{ start: null, end: null }
Period { start, end } with YYYY-MM-DD dates, or null.

Slots

Name
Slot props
Description
actions
any
Buttons under the calendar next to "Today".

Exposed

Name
Type
Description
focus
() => void
Moves the focus into the field.
open
() => void
Opens the calendar and moves the focus into it.
close
() => void
Closes the calendar without returning the focus to the field.

Texts

Key
Russian
English
clear
Очистить
Clear
dayGlyph
Д
D
dialog
Календарь
Calendar
end
Дата окончания
End date
monthGlyph
М
M
open
Выбрать дату
Choose date
openRange
Выбрать период
Choose dates
timeGlyphs
ЧЧ:ММ
HH:mm
yearGlyph
Г
Y

Edit this page

Search

Esc