Fragiola

API: components

DatePicker

A trigger and a non-modal popup holding a bound Calendar, which opens on the chosen date, closes on a choice and returns focus to the trigger.

A trigger and a non-modal popup holding a Calendar. The popup is a dialog disclosed by a button, as a Popover (WAI-ARIA APG dialog pattern, without the modal parts), and the calendar inside keeps the keyboard of the APG date picker dialog example. A start and an end date is a DateRangePicker. Its calendar can take presets and day, month and year views; a month or a year alone is a MonthPicker or a YearPicker.

The Calendar inside the Popup has no value of its own: it binds to the picker, showing its value and setting it, and takes the picker's calendar options (min, max, locale, ...). The picker renders no text: the trigger's content is the consumer's (the formatted value, for example), and so is the popup's name (aria-label).

Booking form
Gallery

Behaviour

  • Open: a press on the Trigger toggles it. The calendar focuses its focused date: the value (the chosen date), else today, kept inside min and max.
  • Choose: choosing a date sets the value, closes the popup (reason item-press) and focuses the Trigger.
  • Close: Escape (escape-key) and the Trigger (trigger-press) return focus to the trigger; a press outside (outside-press) returns it unless the press landed on a focusable element.
  • Tab order: focus is not trapped. The popup's content comes right after the trigger: Tab from its last element moves on and closes it, Shift+Tab from its first goes back to the trigger and closes it (focus-out).
  • Positioning: as a Popover's, below the trigger and aligned to its start by default.
  • Forms: with a name, the Root renders a hidden input after its children, which the form submits as name=<ISO date> (arrival=2026-11-24), or an empty value with no date. required blocks a native submission with no date and focuses the Trigger; disabled disables the Trigger and submits nothing; readOnly still opens the popup, whose calendar can be browsed but chooses nothing, and still submits. A form reset returns an uncontrolled picker to its defaultValue (a controlled one reports it through onValueChange, reason none).
  • Field: inside a Field, the field's name and disabled win, the Trigger is the labelled element and the focus target, validate receives the date (or null), and the hidden input is the validated element. The Trigger is named by the Field's Label, then its own content ("Arrival 2026-11-24"), so its visible text stays in its name; a click on the Label only focuses it, and opens nothing. A Fieldset's disabled disables it too.
  • Lifecycle: onOpenChange is called before the change (details.cancel() keeps it as it is, change details), onOpenChangeComplete(open) reports the end of each transition, the actions close() and unmount() act from code, and the Portal's keepMounted keeps the Positioner in the page while closed (hidden, data-closed).

Anatomy

partelementdata-primitives-partrole
Rootnoneholds the value and the open state
Triggerbuttondate-picker-triggertoggles the popup, and anchors it
Portalnonemoves the Positioner to the end of body
Positionerdivdate-picker-positionerplaces the popup next to the trigger
Popupdivdate-picker-popupthe non-modal dialog, holding a Calendar.Root
(hidden input)inputdate-picker-inputrendered after the Root's children while it has a name (or a Field's): what the form submits

Usage

import { Calendar } from "@fragiola/primitives-react/calendar";
import { DatePicker, type PlainDate } from "@fragiola/primitives-react/date-picker";

const [value, setValue] = useState<PlainDate | null>(null);

<DatePicker.Root value={value} onValueChange={setValue} locale="en-US">
    <DatePicker.Trigger>{value ? format(value) : "Choose a date"}</DatePicker.Trigger>
    <DatePicker.Portal>
        <DatePicker.Positioner sideOffset={4}>
            <DatePicker.Popup aria-label="Choose a date">
                <Calendar.Root>
                    {/* its Heading, page buttons and Grid, as on the Calendar page */}
                </Calendar.Root>
            </DatePicker.Popup>
        </DatePicker.Positioner>
    </DatePicker.Portal>
</DatePicker.Root>;

Props

Every part also takes what the primitive contract gives. The names below are React's; Vue binds them the same way (v-model:value, v-model:open, :side-offset), and Angular as inputs and outputs ([(value)], [(open)], (valueChangeDetails), (openChangeDetails)).

Root

proptypedefaultdescription
valuePlainDate | nullthe chosen date, controlled
defaultValuePlainDate | nullnullthe initial date, uncontrolled
onValueChange(value: PlainDate | null, details: { reason }) => voidevery choice (reason item-press)
openbooleanthe open state, controlled
defaultOpenbooleanfalsethe initial open state, uncontrolled
onOpenChange(open: boolean, details: OpenChangeDetails) => voidevery change, with its reason (trigger-press, item-press, escape-key, outside-press, focus-out); called before the change, details.cancel() stops it
onOpenChangeComplete(open: boolean) => voidonce an opening or a closing has finished its transitions (not on the first render, nor for an exit a reopening interrupted)
actionsRef (react){ current: OverlayActions | null }receives close() (reason imperative-action) and unmount() (ends an exit now); Vue exposes them on the Root's template ref, Angular as the root directive's methods
minPlainDate | nullpassed to the bound calendar
maxPlainDate | nullpassed to the bound calendar
isDateUnavailable(date: PlainDate) => booleanpassed to the bound calendar
localestringthe document's langpassed to the bound calendar
calendarCalendarSystemthe ISO calendara calendar system, passed to the bound calendar; the value stays ISO
firstDayOfWeeknumberthe locale'spassed to the bound calendar
visibleMonthsnumber1passed to the bound calendar
namestringthe hidden input's form name (a Field's wins); without one, no input is rendered
requiredbooleanfalsea native form's validation blocks a submission with no date
disabledbooleanfalsethe Trigger cannot open the popup; the hidden input submits nothing
readOnlybooleanfalsethe popup still opens; its calendar can be browsed, no date chosen

Trigger

No props of its own.

Portal

proptypedefaultdescription
container (react, vue)Elementdocument.bodywhere the Positioner goes
keepMounted (react, vue)booleanfalsekeep the content rendered while closed (before the first opening and after an exit), hidden and data-closed; reopening shows the same elements
options (angular)Element | { container?, keepMounted? }{}the same two options: *datePickerPortal="{ keepMounted: true }", or *datePickerPortal="element" for a container alone

Positioner

proptypedefaultdescription
side"top" | "bottom" | "inline-start" | "inline-end" | "left" | "right""bottom"the side of the trigger
align"start" | "center" | "end""start"the alignment along that side
sideOffsetnumber0the distance from the trigger, in px
alignOffsetnumber0the shift along its edge, in px
collisionPaddingnumber8the space kept from the viewport's edges, in px
anchorElementthe triggerthe element to place the popup next to

No props of its own.

State and part attributes

partattributes
Triggertype="button", aria-haspopup="dialog", aria-expanded, aria-controls (the popup while open), data-popup-open; disabled and data-disabled while disabled, data-readonly while read-only, data-required while required; in a Field, its ids, aria-labelledby (the Label, then itself), aria-describedby, aria-invalid and the field's states
Positionerrole="presentation", data-side, data-align, data-open / data-closed; the CSS variables --anchor-width, --anchor-height, --available-width, --available-height, --transform-origin; hidden while kept mounted and closed
Popuprole="dialog" (no aria-modal), an id, data-side, data-align, data-open / data-closed, data-starting-style, data-ending-style
hidden inputname, value (ISO), required, disabled, aria-hidden="true", tabindex="-1"; visually hidden (a text input, which the browser validates, not type="hidden")

Keyboard

keyaction
Enter, Space on the Triggertoggles
the calendar's keysas on the Calendar page; choosing a date closes
Tabthrough the popup; from its last element, to the element after the trigger, closing it
Shift+Tabfrom the popup's first element, back to the trigger, closing it
Escapecloses, focus on the trigger

Exports

entryexports
@fragiola/primitives-react/date-pickerDatePicker, Align, CalendarOptions, ChangeDetails, ChangeReason, DatePickerPopupProps, DatePickerPopupState, DatePickerPortalProps, DatePickerPositionerProps, DatePickerPositionerState, DatePickerRootProps, DatePickerRootSharedProps, DatePickerTriggerProps, DatePickerTriggerState, PlainDate, PositionerProps, RenderProp, Side, OpenChangeDetails, OverlayActions, OverlayPortalProps, OverlayRootProps
@fragiola/primitives-vue/date-pickerDatePicker, Align, CalendarOptions, ChangeDetails, ChangeReason, DatePickerPopupProps, DatePickerPopupState, DatePickerPortalProps, DatePickerFormProps, DatePickerPositionerState, DatePickerRootEmits, DatePickerRootProps, DatePickerRootSharedProps, DatePickerTriggerProps, DatePickerTriggerState, PlainDate, PositionerProps, RenderSlotProps, Side, OpenChangeDetails, OverlayActions, OverlayPortalProps, OverlayRootEmits, OverlayRootProps
@fragiola/primitives-angular/date-pickerDatePickerRoot, Align, CalendarOptions, CalendarValue, ChangeDetails, ChangeReason, createDatePicker, DATE_PICKER, DatePickerComponent, DatePickerInputs, DatePickerPopup, DatePickerPopupState, DatePickerPortal, DatePickerPositioner, DatePickerPositionerState, DatePickerRootBase, DatePickerState, DatePickerTrigger, DatePickerTriggerData, DatePickerTriggerState, injectDatePicker, OpenChangeEvent, PickerComponent, PlainDate, Side, ValueChangeEvent, OpenChangeDetails, OverlayActions, OverlayPortalOptions