Skip to content
SENVENLI UI

Date picker

A date field with a calendar popover, Today and Clear actions, markers and unavailable days.
A date with a calendar
import { DatePicker } from "@senvenli/react/date";

Examples

Unavailable days and markers

Closed days stay visible and say why; a dot marks days worth a look.

With a range

Days outside `minValue` and `maxValue` cannot be picked or typed.

A month

For a report period: the popover is a grid of months.

In Spanish

The locale names the months and days and orders the date; the label is yours.

In Arabic, right to left

`dir="rtl"` mirrors the field and the calendar; digits follow the locale.

A range: A period

Start and end in one control over one calendar.

A range: With times

`granularity="hour"` adds a start and an end time.

A range: Named halves and a total

Your own labels for the two halves, and a figure beside the day count under the calendar.

Guidelines

When to use it

  • Picking a date where seeing the month helps.
  • Picking a period: a stay, a trip, a report range.

Use something else when

  • People type a known date, such as a birth date, and a calendar adds nothing. Date field
  • The month grid stays visible on the page. Calendar

Accessibility

Keyboard

KeysWhat happens
Alt + Arrow downOpens the calendar.

Built in

  • Unavailable days explain why.
  • Required fields show "Fill in this field."; a partly typed date says what is missing.
  • Both halves are labelled ("Start", "End") and typed independently.
  • The range may not cross an unavailable day unless allowed.

You provide

  • A visible label.
  • A label for the range.

API reference

DatePicker

defaultValue
CalendarDate | DateRangePickerValue
autoFocus
boolean
id
string

The id of the field's first typed segment (day, or the locale's first part), the element that takes focus : document.getElementById(id).focus() puts the user in the field, as a focus-on-error does. The field's group gets an id of its own. Left out, the DOM is as before.

onBlur
(event: FocusEvent<Element, Element>) => void
onChange
(value: CalendarDate | null) => void | (value: DateRangePickerValue | null) => void
isDisabled
boolean
name
string

The form field name; the value is submitted as an ISO string.

labelRequired
React.ReactNode

Always given; the label sits above the field and names its segments.

description
React.ReactNode
errorMessage
React.ReactNode

What happened and what to do; shown when the field is invalid.

isRequired
boolean
requiredValidation
RequiredValidation

Who says an empty required field is missing: field (default) or app. With app a DS Form's onSubmit runs with the field empty, and the app's own error must clear on change. See {@link RequiredValidation} for the whole contract.

isOptional
boolean

Shows "(optional)" when most of the form is required.

isReadOnly
boolean
isInvalid
boolean

Marks the field invalid from outside (a server error); errorMessage says why.

minValue
CalendarDate | DateValue
maxValue
CalendarDate | DateValue
validate
(value: CalendarDate | null) => string | true | string[] | null | undefined | (value: Span<DateValue> | null) => string | true | string[] | null | undefined

Your own check; return the message to show, or nothing when the date is fine.

value
CalendarDate | DateRangePickerValue

A calendar date, no time zone; with granularity="month" the month's first day.

While the user leaves a date typed in part or impossible ("31.aa.2026", "31.11.2026"), the field reports onChange(null) and keeps the typed parts on screen, so setting null changes nothing: the value already is null. To clear the field (an app's own "Temizle" or form reset), give it a new key along with the value: React remounts it empty, or at the value given.

isDateUnavailable
(date: CalendarDate) => boolean
unavailableReason
(date: CalendarDate) => string | undefined
getDateMarkers
(date: CalendarDate) => DateMarker | undefined
firstDayOfWeek
FirstDayOfWeek
timeZone
string

"Today" in the calendar and the Today action: the location's zone; the device's by default.

shouldCloseOnSelect
boolean

Close the calendar once a day is picked (default).

granularity
"day" | "month" | "day" | "hour"

month: a year and a month, for a report or history range. The field types month and year (as DateField granularity="month"), the value is that month's first day, and the popover is a grid of the twelve months under a year stepper, with "This month" and "Clear"; minValue and maxValue count by month. The day-only props (unavailable days, markers, first day of the week) do not apply. Default day.

selectionMode
"single" | "range"

single (default): one date (and time with granularity="hour").

allowsNonContiguousRanges
boolean
startLabel
string

Overline labels of the two halves; "Start" and "End" by default.

endLabel
string
footer
React.ReactNode

Right of the duration under the calendar: the price total (metric-small).

startName
string

Form field names for the two halves (ISO strings).

endName
string