Skip to content

ODatepicker ​

ODatepicker is a labelled calendar field for controlled local-day, range, week, month, and multiple-date selection.

Usage ​

Step by step ​

  1. Import ODatepicker from the ooko-ui/datepicker public subpath.
  2. Bind the controlled model with v-model and provide the required label.
  3. Type a date in the format indicated by the field or open the calendar to make the same selection. The locale prop controls that visible format.

Example ​

The rendered example and its source come from the same Vue single-file component.

Selected: 15/09/2026.

Interactive playground ​

Change the selection type, field state, and calendar options. The preview updates immediately.

Selected: 15/09/2026.

Type the locale format, or open the calendar.

Props ​

PropTypeDefaultDescription
sizeOokoFormControlSize"md"Controls the datepicker's form-control scale.
labelstringundefinedVisible or visually hidden accessible label.
idstringundefinedText-input identifier; a hydration-safe identifier is generated when omitted.
namestringundefinedNative form field name and OForm validation key.
hintstringundefinedPersistent field guidance.
errorstringundefinedControlled validation error.
validationOokoValidationBindingundefinedExplicit binding created by useOokoValidation.
hideLabelbooleanfalseVisually hides the label while preserving its accessible name.
requiredbooleanfalseRequires a selection.
disabledbooleanfalsePrevents interaction and native form submission.
readonlybooleanfalseKeeps the text input focusable while preventing selection changes.
clearablebooleanfalseDisplays an empty-value action next to the input.
iconComponentundefinedVue component rendered as a decorative field icon.
iconPositionOFieldIconPositionundefinedPlaces the decorative field icon before or after the datepicker controls.
placeholderstringundefinedContent shown when no value is selected.
localestring"en-GB"BCP 47 locale used to format and parse visible calendar dates.
minDatestringundefinedEarliest selectable local calendar day, inclusive.
maxDatestringundefinedLatest selectable local calendar day, inclusive.
displayWeekNumberbooleanfalseDisplays ISO week numbers beside calendar rows.
typeODatepickerType"date"Selects one day, range, ISO week, month, or multiple local days.
modelValueODatepickerValueundefinedControlled value whose shape corresponds to the selected type.

Events ​

EventPayloadDescription
update:modelValuestring | ODatepickerRange | readonly ODatepickerDate[] | nullEmits the controlled selection after a complete valid typed date, calendar choice, or clear action.

Slots ​

SlotPropsDescription
iconnoneProvides custom decorative field icon markup and overrides the icon prop.
TypeDefinition
ODatepickerDatetype ODatepickerDate = string;
ODatepickerRangetype ODatepickerRange = readonly [ODatepickerDate, ODatepickerDate];
ODatepickerTypetype ODatepickerType = "date" | "multiple" | "month" | "range" | "week";
ODatepickerValuetype ODatepickerValue = ODatepickerDate | ODatepickerRange | readonly ODatepickerDate[] | null;

CSS custom properties ​

Custom propertyDefaultDescription
--o-datepicker-panel-width20remMaximum calendar popup width.
--o-datepicker-panel-radiusvar(--o-radius-surface)Calendar popup corner radius.
--o-datepicker-day-size2.25remCalendar day control minimum size.

Override example ​

css
:root {
  --o-datepicker-panel-width: 24rem;
  --o-datepicker-day-size: 2.5rem;
}

Accessibility ​

  • The required label names the editable text input; hideLabel preserves that accessible name.
  • The input opens a labelled nonmodal dialog on click or with Arrow Down. Escape closes it while preserving input focus. Date grids support arrow keys, Home, End, Page Up, Page Down, Enter, and Space; month and year grids expose their active cell during arrow-key navigation. The week dialog exposes a list of selectable week ranges.
  • A click on a day, month, or year segment selects that segment; a click beside the text selects the full value. Up and Down adjust the segment containing the caret or the selected segment, while Left and Right move between selected segments. The datepicker does not render a separate calendar trigger.
  • The input automatically inserts its locale separators while typing. locale="fr-FR" uses DD/MM/YYYY; en-GB uses the same day-first order; en-US uses MM/DD/YYYY.
  • In single-date mode, typing replaces the active section without shifting the others. A first digit that cannot begin a two-digit day or month is zero-padded (4 becomes 04, 9 becomes 09 for a month). Completing a section selects the next one in locale order; the day limit follows the displayed month and year.
  • A complete, valid single date updates the controlled model and calendar highlight while typing. Incomplete, invalid, or out-of-bounds text preserves the last accepted selection. Bounds errors identify the earliest or latest allowed date rather than requesting a different format.
  • The calendar header opens a direct month view or a decade-based year view. In range mode, the first click anchors either endpoint and hovering previews the ordered range in either direction, replacing the previous highlight. Tentative and accepted ranges form continuous bands, with only the outer endpoint corners rounded.
  • Week mode announces and displays a list of ISO week numbers with their From … to … ranges. The field keeps that week label and range when focused. Month mode displays its localized month name and year. Multiple mode renders every selected day as a removable chip.
  • Invalid typed values remain visible, set aria-invalid, and expose an inline validation message. Dates outside minDate and maxDate cannot be typed or selected.
  • Disabled input uses native disabled behavior. Read-only input remains focusable and does not change the controlled model.
  • Focus is visibly indicated, and forced-colors mode maintains calendar control borders and selected-state contrast.

Behavior and edge cases ​

  • Values are ISO local calendar strings rather than Date objects, which makes server rendering and time-zone handling deterministic. locale changes only the visible format, never the emitted model. The component deliberately does not recreate Orion's optional time editor.
  • date, week, and month emit a string or null; range emits an ordered two-item tuple or null; multiple emits an ordered string array. Week values are the Monday that starts the ISO week.
  • A range click first sets a temporary start; the second click emits the ordered inclusive range and closes the dialog. Typing a range emits once its two valid bounds are parsed.
  • Opening the popup from the input preserves input focus. Leaving the datepicker closes the popup; moving focus into its calendar keeps it open. Selecting a single date, week, month, or complete range closes it and restores focus to the input. Multiple selection stays open.
  • Leaving the empty typing area in multiple mode preserves the selected chips. A required multiple-date field validates the selected collection, not the text used to add another date.
  • Parent model updates replace the displayed text even while focused. Valid calendar choices clear previous typing errors; unchanged month and week displays remain valid on Enter and blur.
  • Form submission uses hidden ISO values for the selected dates. A disabled component contributes no values.