Command palette

@yasinsensoy/web

Web · Components

DatePicker

Date picker.

15 exports

Live example

Preview

Type (28102026) or pick from the calendar.

Code

import { Form, DateField, SubmitButton } from "@yasinsensoy/web";

<Form action={formAction} state={state}>
  <DateField label="Due date" name="date" clearable required description="Type (28102026) or pick from the calendar." tooltip="Weekend delivery costs extra."
    min={new Date()}
    messages={{ valueMissing: "Pick a date", rangeUnderflow: "You can't pick a past date" }} />
  <SubmitButton>Submit</SubmitButton>
</Form>

// Server action
async function save(_: unknown, data: FormData) {
  const date = parseISODate(String(data.get("date"))); // Date | undefined
}

Events

  1. Events appear here when you interact with the preview.

Birth date: future disabled, long display

Appointment: with time, 15-minute steps, Sundays disabled

We're closed on Sundays.

Import

import {
  DatePicker,
  DateRangePicker,
  MonthPicker,
  YearPicker,
  TimePicker,
} from "@yasinsensoy/web";

DatePicker

componentClient component

Date picker. The day is typed (28102026 → 28.10.2026) or picked from the dropdown calendar; with time a time is picked too.

  • Typing: Separators are added automatically per the locale format (tr-TR: DD.MM.YYYY); short forms like 5.3.26 are understood too. When the date is complete, the calendar moves to that day. Invalid or out-of-range text reverts to the old value on blur.
  • Calendar: Opens on click or with ↓; month and year views, keyboard navigation, min/max/isDateDisabled, week numbers and marked days work as in Calendar. Closes when a day is picked.
  • Presets: "Today", "Tomorrow" or your own options with presets.
  • Mobile: The keyboard does not open; a tap opens a bottom calendar sheet with large cells, and swiping left/right changes the month. Closes by pulling down and with the back button.
  • Form: With name, "YYYY-MM-DD" (with time "YYYY-MM-DDTHH:mm") is submitted; required, min and max work with browser validation. On the server, convert it to a Date with parseISODate.

For use with a label, description and error message, see DateField.

DatePicker(props: DatePickerProps): JSX.Element

Examples

<DatePicker name="birthDate" max={new Date()} format={{ dateStyle: "long" }} />

<DatePicker value={date} onValueChange={(iso) => setDate(iso)} clearable
  presets={["today", "tomorrow", { label: "In 1 week", value: () => inOneWeek() }]} />

<DatePicker name="appointment" time minuteStep={15} min={new Date()}
  isDateDisabled={(d) => d.getDay() === 0} />

DateRangePicker

componentClient component

Date range picker. Start and end are typed into two side-by-side fields or picked with two clicks in the dropdown two-month calendar (the range is previewed in between).

  • Preset ranges: presets={["last7Days", "thisMonth", "lastMonth"]} or your own ranges with { label, value }.
  • Bounds: min, max, isDateDisabled; range length with minDays/maxDays. The selected day count is shown at the bottom of the panel.
  • Typing: Each field is formatted like DatePicker; if the end is before the start, the ends are swapped.
  • Mobile: The keyboard does not open; a one-month calendar sheet opens from the bottom, and preset ranges are scrollable buttons on top.
  • Form: With name, an ISO 8601 range "2026-10-01/2026-10-07" is submitted (once both ends are picked); required needs both ends. On the server, split it with parseDateRange.

For use with a label, description and error message, see DateRangeField.

DateRangePicker(props: DateRangePickerProps): JSX.Element

Examples

<DateRangePicker name="period" presets={["last7Days", "last30Days", "thisMonth"]} />

<DateRangePicker value={range} onValueChange={setRange} min={new Date()} maxDays={14}
  isDateDisabled={(d) => bookedDays.has(toISODate(d))} />

MonthPicker

componentClient component

Month picker: the month is typed (102026 → 10.2026) or picked from the dropdown month grid. For fields that need no day, such as a billing period, card expiry date or monthly report.

  • Typing: 10.2026, 10/26, 1026, 2026-10 are understood; invalid or out-of-range text reverts to the old value on blur.
  • Panel: the months of the year in a 3×4 grid; clicking the year shows the year grid. Months are disabled with min, max, isMonthDisabled.
  • Display: "October 2026" while not focused (changed with format).
  • Mobile: the keyboard does not open; a bottom panel with large cells opens, closed by pulling down and with the back button.
  • Form: With name, "YYYY-MM" is submitted (the native <input type="month"> format); required, min, max work with browser validation. On the server, convert it to a Date with parseISOMonth.

For labeled use, see MonthField.

MonthPicker(props: MonthPickerProps): JSX.Element

Examples

<MonthPicker name="period" max={new Date()} presets={["thisMonth", "lastMonth"]} />

<MonthPicker value={expiry} onValueChange={setExpiry} min={new Date()}
  monthFormat="numeric" format={false} placeholder="MM/YY" />

YearPicker

componentClient component

Year picker: the year is typed or picked from the dropdown 12-year grid (model year, graduation year, annual report).

  • Years are disabled with min, max, isYearDisabled.
  • Form: With name, "YYYY" is submitted; required, min, max work with browser validation.

For labeled use, see YearField.

YearPicker(props: YearPickerProps): JSX.Element

Examples

<YearPicker name="model" min={1990} max={new Date().getFullYear() + 1} clearable />

TimePicker

componentClient component

Time picker. Typed ("1430" → 14:30) or picked from the hour and minute columns of the dropdown panel.

  • : is added automatically while typing; loose forms like 9, 930, 9.30 are understood too. Unparsable text reverts to the old value on blur.
  • Columns change with ↑/↓; the panel closes when a minute is picked.
  • Times outside min/max are disabled in the columns and checked by browser validation (rangeUnderflow/rangeOverflow).
  • Mobile: The keyboard does not open; a tap opens a bottom sheet with columns. Closes by pulling down and with the back button.
  • Form: With name, "HH:mm" is submitted; required works, and it returns to the initial value when the form is reset.

For use with a label, description and error message, see TimeField.

TimePicker(props: TimePickerProps): JSX.Element

Examples

<TimePicker name="time" defaultValue="09:30" minuteStep={15} />

<TimePicker value={time} onValueChange={setTime} min="09:00" max="18:00" clearable />

Presets of the single date picker.

type DatePreset = "today" | "yesterday" | "tomorrow" | { /** Button text. */ label: ReactNode; /** Day to select or a function computing it (e.g. "Next Monday"). */ value: DateInput | (() => DateInput); }

Presets of the date range picker.

type DateRangePreset = "today" | "yesterday" | "last7Days" | "last30Days" | "thisWeek" | "thisMonth" | "lastMonth" | "thisYear" | { /** Button text. */ label: ReactNode; /** Range to select or a function computing it. */ value: DateRangeInput | (() => DateRangeInput); }

Props of the DatePicker component.

Extends: Pick<CalendarBaseProps, "min" | "max" | "isDateDisabled" | "weekStartsOn" | "showWeekNumbers" | "marks">

NameTypeDefaultDescription
value?DateInputSelected day when controlled: "2026-10-28" (with time "2026-10-28T14:30") or a Date; "" for none.
defaultValue?DateInputInitial day when uncontrolled.
onValueChange?(value: string, date: Date | undefined) => voidCalled with the ISO text and a Date when the selection changes ("" and undefined when cleared). With time, the text is in "YYYY-MM-DDTHH:mm" format.
time?booleanfalseShould a time be selected along with the date? Hour and minute columns appear next to the calendar in the panel; the value switches to the "2026-10-28T14:30" format.
minuteStep?number5Step of the minute list when using time.
presets?readonly DatePreset[]Presets in the panel: "today", "yesterday", "tomorrow" or { label, value }. Shown to the left of the calendar on desktop and as scrollable buttons above it on mobile.
todayButton?booleantrue` when there are no `presets"Today" button at the bottom of the panel.
format?Intl.DateTimeFormatOptionsDisplay format of the value while the field is not focused (e.g. { dateStyle: "long" } → "October 28, 2026"). If omitted, the numeric format used while typing (28.10.2026) is used.
variant?FieldVariant | CustomVariant<"field">Appearance: outline (bordered), filled, underline or ghost (plain). If omitted, the setting of the nearest data-field-variant container is used, or outline if there is none. See FieldVariant.
effect?EffectPropEffect or effects of the field box (e.g. "glow", ["lift", "beam"]). The accent color is the focus color (--ui-field-focus). If omitted, UIProvider appearance.defaults.field.effect. See BuiltinEffect.
name?stringForm field name; the value is submitted under this name in ISO format.
form?stringId of the form the field belongs to (if outside the form).
required?booleanThe form cannot be submitted without a value.
disabled?booleanDisabled.
readOnly?booleanThe value is visible but cannot be changed; the panel does not open.
id?stringId of the text field; <Label htmlFor> binds to it.
autoFocus?booleanFocused when the page opens.
placeholder?stringText shown when empty. If omitted, the locale format (DD.MM.YYYY).
clearable?booleanfalseShow the × button that clears the value?
icon?IconPropIcon at the start of the box.
side?Placement"auto"Position of the panel relative to the field. See Placement. On mobile the panel is a bottom sheet.
open?booleanWhether the panel is open when controlled.
defaultOpen?booleanfalseIs it initially open when uncontrolled?
onOpenChange?(open: boolean) => voidCalled when the panel opens or closes.
tooltip?TooltipPropHint shown when hovering the box. In labeled fields the hint is shown on the ⓘ icon next to the label. See TooltipProp.
className?stringClasses added to the container (e.g. w-56 for width).
classNames?PickerClassNamesClasses added to the inner parts.
aria-label?stringScreen reader name when there is no visible label.
aria-labelledby?stringId of the element naming the field.
aria-describedby?stringId of the element describing the field. Ready-made fields set it themselves.
aria-invalid?boolean | "true" | "false"Show the field as invalid (red border). Ready-made fields set it themselves.

Props of the DateRangePicker component.

Extends: Pick<CalendarBaseProps, "min" | "max" | "isDateDisabled" | "weekStartsOn" | "showWeekNumbers" | "marks">

NameTypeDefaultDescription
value?DateRangeInputSelected range when controlled.
defaultValue?DateRangeInputInitial range when uncontrolled.
onValueChange?(range: DateRange) => voidCalled when the range changes; end is empty until the end is selected.
minDays?numberMinimum number of days in the range (both ends included).
maxDays?numberMaximum number of days in the range (both ends included).
months?number2Number of months shown side by side on desktop; always 1 on mobile.
presets?readonly DateRangePreset[]Preset ranges: "today", "yesterday", "last7Days", "last30Days", "thisWeek", "thisMonth", "lastMonth", "thisYear" or { label, value }. A column on the left on desktop, a button row on top on mobile.
variant?FieldVariant | CustomVariant<"field">Appearance: outline (bordered), filled, underline or ghost (plain). If omitted, the setting of the nearest data-field-variant container is used, or outline if there is none. See FieldVariant.
effect?EffectPropEffect or effects of the field box (e.g. "glow", ["lift", "beam"]). The accent color is the focus color (--ui-field-focus). If omitted, UIProvider appearance.defaults.field.effect. See BuiltinEffect.
name?stringForm field name; the value is submitted under this name in ISO format.
form?stringId of the form the field belongs to (if outside the form).
required?booleanThe form cannot be submitted without a value.
disabled?booleanDisabled.
readOnly?booleanThe value is visible but cannot be changed; the panel does not open.
id?stringId of the text field; <Label htmlFor> binds to it.
autoFocus?booleanFocused when the page opens.
placeholder?stringText shown when empty. If omitted, the locale format (DD.MM.YYYY).
clearable?booleanfalseShow the × button that clears the value?
icon?IconPropIcon at the start of the box.
side?Placement"auto"Position of the panel relative to the field. See Placement. On mobile the panel is a bottom sheet.
open?booleanWhether the panel is open when controlled.
defaultOpen?booleanfalseIs it initially open when uncontrolled?
onOpenChange?(open: boolean) => voidCalled when the panel opens or closes.
tooltip?TooltipPropHint shown when hovering the box. In labeled fields the hint is shown on the ⓘ icon next to the label. See TooltipProp.
className?stringClasses added to the container (e.g. w-56 for width).
classNames?PickerClassNamesClasses added to the inner parts.
aria-label?stringScreen reader name when there is no visible label.
aria-labelledby?stringId of the element naming the field.
aria-describedby?stringId of the element describing the field. Ready-made fields set it themselves.
aria-invalid?boolean | "true" | "false"Show the field as invalid (red border). Ready-made fields set it themselves.

Presets in the MonthPicker panel.

type MonthPreset = "thisMonth" | "lastMonth" | { /** Button text. */ label: ReactNode; /** Month to select (`"2026-10"`, a date) or a function computing it. */ value: DateInput | (() => DateInput); }

Props of the MonthPicker component.

Extends: Pick<MonthCalendarProps, "min" | "max" | "isMonthDisabled" | "monthFormat">

NameTypeDefaultDescription
value?DateInputSelected month when controlled: "2026-10", a date string or a Date; "" for none.
defaultValue?DateInputInitial month when uncontrolled.
onValueChange?(value: string, date: Date | undefined) => voidCalled with "YYYY-MM" and the first day of the month when the selection changes ("", undefined when cleared).
format?Intl.DateTimeFormatOptions | false{ month: "long", year: "numeric" }Display format of the value while the field is not focused. If omitted, with the month name ("October 2026"); if false, in the typed format (10.2026).
presets?readonly MonthPreset[]Presets: "thisMonth", "lastMonth" or { label, value }.
currentButton?booleantrue` when there are no `presets"This month" button at the bottom of the panel.
variant?FieldVariant | CustomVariant<"field">Appearance: outline (bordered), filled, underline or ghost (plain). If omitted, the setting of the nearest data-field-variant container is used, or outline if there is none. See FieldVariant.
effect?EffectPropEffect or effects of the field box (e.g. "glow", ["lift", "beam"]). The accent color is the focus color (--ui-field-focus). If omitted, UIProvider appearance.defaults.field.effect. See BuiltinEffect.
name?stringForm field name; the value is submitted under this name in ISO format.
form?stringId of the form the field belongs to (if outside the form).
required?booleanThe form cannot be submitted without a value.
disabled?booleanDisabled.
readOnly?booleanThe value is visible but cannot be changed; the panel does not open.
id?stringId of the text field; <Label htmlFor> binds to it.
autoFocus?booleanFocused when the page opens.
placeholder?stringText shown when empty. If omitted, the locale format (DD.MM.YYYY).
clearable?booleanfalseShow the × button that clears the value?
icon?IconPropIcon at the start of the box.
side?Placement"auto"Position of the panel relative to the field. See Placement. On mobile the panel is a bottom sheet.
open?booleanWhether the panel is open when controlled.
defaultOpen?booleanfalseIs it initially open when uncontrolled?
onOpenChange?(open: boolean) => voidCalled when the panel opens or closes.
tooltip?TooltipPropHint shown when hovering the box. In labeled fields the hint is shown on the ⓘ icon next to the label. See TooltipProp.
className?stringClasses added to the container (e.g. w-56 for width).
classNames?PickerClassNamesClasses added to the inner parts.
aria-label?stringScreen reader name when there is no visible label.
aria-labelledby?stringId of the element naming the field.
aria-describedby?stringId of the element describing the field. Ready-made fields set it themselves.
aria-invalid?boolean | "true" | "false"Show the field as invalid (red border). Ready-made fields set it themselves.

Props of the YearPicker component.

NameTypeDefaultDescription
value?YearInputSelected year when controlled: 2026, "2026" or a Date; "" for none.
defaultValue?YearInputInitial year when uncontrolled.
onValueChange?(value: string, year: number | undefined) => voidCalled with the "YYYY" text and the year number when the selection changes ("", undefined when cleared).
min?YearInputEarliest selectable year.
max?YearInputLatest selectable year.
isYearDisabled?(year: number) => booleanFunction for years that cannot be selected.
currentButton?booleantrue"This year" button at the bottom of the panel.
variant?FieldVariant | CustomVariant<"field">Appearance: outline (bordered), filled, underline or ghost (plain). If omitted, the setting of the nearest data-field-variant container is used, or outline if there is none. See FieldVariant.
effect?EffectPropEffect or effects of the field box (e.g. "glow", ["lift", "beam"]). The accent color is the focus color (--ui-field-focus). If omitted, UIProvider appearance.defaults.field.effect. See BuiltinEffect.
name?stringForm field name; the value is submitted under this name in ISO format.
form?stringId of the form the field belongs to (if outside the form).
required?booleanThe form cannot be submitted without a value.
disabled?booleanDisabled.
readOnly?booleanThe value is visible but cannot be changed; the panel does not open.
id?stringId of the text field; <Label htmlFor> binds to it.
autoFocus?booleanFocused when the page opens.
placeholder?stringText shown when empty. If omitted, the locale format (DD.MM.YYYY).
clearable?booleanfalseShow the × button that clears the value?
icon?IconPropIcon at the start of the box.
side?Placement"auto"Position of the panel relative to the field. See Placement. On mobile the panel is a bottom sheet.
open?booleanWhether the panel is open when controlled.
defaultOpen?booleanfalseIs it initially open when uncontrolled?
onOpenChange?(open: boolean) => voidCalled when the panel opens or closes.
tooltip?TooltipPropHint shown when hovering the box. In labeled fields the hint is shown on the ⓘ icon next to the label. See TooltipProp.
className?stringClasses added to the container (e.g. w-56 for width).
classNames?PickerClassNamesClasses added to the inner parts.
aria-label?stringScreen reader name when there is no visible label.
aria-labelledby?stringId of the element naming the field.
aria-describedby?stringId of the element describing the field. Ready-made fields set it themselves.
aria-invalid?boolean | "true" | "false"Show the field as invalid (red border). Ready-made fields set it themselves.

Classes that can be passed to the inner parts of the date and time pickers.

NameTypeDescription
box?stringThe visible box of the field (text field and buttons).
input?stringText field (both fields in a range).
content?stringDropdown panel.

Props shared by all date/time pickers.

NameTypeDefaultDescription
variant?FieldVariant | CustomVariant<"field">Appearance: outline (bordered), filled, underline or ghost (plain). If omitted, the setting of the nearest data-field-variant container is used, or outline if there is none. See FieldVariant.
effect?EffectPropEffect or effects of the field box (e.g. "glow", ["lift", "beam"]). The accent color is the focus color (--ui-field-focus). If omitted, UIProvider appearance.defaults.field.effect. See BuiltinEffect.
name?stringForm field name; the value is submitted under this name in ISO format.
form?stringId of the form the field belongs to (if outside the form).
required?booleanThe form cannot be submitted without a value.
disabled?booleanDisabled.
readOnly?booleanThe value is visible but cannot be changed; the panel does not open.
id?stringId of the text field; <Label htmlFor> binds to it.
autoFocus?booleanFocused when the page opens.
placeholder?stringText shown when empty. If omitted, the locale format (DD.MM.YYYY).
clearable?booleanfalseShow the × button that clears the value?
icon?IconPropIcon at the start of the box.
side?Placement"auto"Position of the panel relative to the field. See Placement. On mobile the panel is a bottom sheet.
open?booleanWhether the panel is open when controlled.
defaultOpen?booleanfalseIs it initially open when uncontrolled?
onOpenChange?(open: boolean) => voidCalled when the panel opens or closes.
tooltip?TooltipPropHint shown when hovering the box. In labeled fields the hint is shown on the ⓘ icon next to the label. See TooltipProp.
className?stringClasses added to the container (e.g. w-56 for width).
classNames?PickerClassNamesClasses added to the inner parts.
aria-label?stringScreen reader name when there is no visible label.
aria-labelledby?stringId of the element naming the field.
aria-describedby?stringId of the element describing the field. Ready-made fields set it themselves.
aria-invalid?boolean | "true" | "false"Show the field as invalid (red border). Ready-made fields set it themselves.

Props of the TimePicker component.

NameTypeDefaultDescription
value?stringSelected time when controlled ("14:30"); "" for none.
defaultValue?stringInitial time when uncontrolled.
onValueChange?(value: string) => voidCalled with "HH:mm" ("" when cleared) when the time changes.
min?stringEarliest selectable time ("09:00").
max?stringLatest selectable time ("18:00").
minuteStep?number5Step of the minute list (e.g. 15 → 00, 15, 30, 45). Any minute can be typed manually.
nowButton?booleantrueShow the "Now" button in the panel?
variant?FieldVariant | CustomVariant<"field">Appearance: outline (bordered), filled, underline or ghost (plain). If omitted, the setting of the nearest data-field-variant container is used, or outline if there is none. See FieldVariant.
effect?EffectPropEffect or effects of the field box (e.g. "glow", ["lift", "beam"]). The accent color is the focus color (--ui-field-focus). If omitted, UIProvider appearance.defaults.field.effect. See BuiltinEffect.
name?stringForm field name; the value is submitted under this name in ISO format.
form?stringId of the form the field belongs to (if outside the form).
required?booleanThe form cannot be submitted without a value.
disabled?booleanDisabled.
readOnly?booleanThe value is visible but cannot be changed; the panel does not open.
id?stringId of the text field; <Label htmlFor> binds to it.
autoFocus?booleanFocused when the page opens.
placeholder?stringText shown when empty. If omitted, the locale format (DD.MM.YYYY).
clearable?booleanfalseShow the × button that clears the value?
icon?IconPropIcon at the start of the box.
side?Placement"auto"Position of the panel relative to the field. See Placement. On mobile the panel is a bottom sheet.
open?booleanWhether the panel is open when controlled.
defaultOpen?booleanfalseIs it initially open when uncontrolled?
onOpenChange?(open: boolean) => voidCalled when the panel opens or closes.
tooltip?TooltipPropHint shown when hovering the box. In labeled fields the hint is shown on the ⓘ icon next to the label. See TooltipProp.
className?stringClasses added to the container (e.g. w-56 for width).
classNames?PickerClassNamesClasses added to the inner parts.
aria-label?stringScreen reader name when there is no visible label.
aria-labelledby?stringId of the element naming the field.
aria-describedby?stringId of the element describing the field. Ready-made fields set it themselves.
aria-invalid?boolean | "true" | "false"Show the field as invalid (red border). Ready-made fields set it themselves.