Fragiola

API: components

DateRangePicker

A trigger and a non-modal popup holding a bound RangeCalendar, which closes on the range's end and returns focus to the trigger, in each framework.

A RangeCalendar in a popup: the DatePicker's trigger, positioner and popup for a range. The popup stays open after the first date and closes on the second. Its RangeCalendar can take presets and views; a range of months or years is a MonthRangePicker or a YearRangePicker.

Its parts are the DatePicker's (WAI-ARIA APG dialog pattern, non-modal): /date-range-picker exports its own Root with them, named date-range-picker-*.

The RangeCalendar 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).

Trip dates
Gallery

Behaviour

  • Open: a press on the Trigger toggles it. The calendar focuses its focused date: the value (the range's start), else today, kept inside min and max.
  • Choose: choosing the range's end 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 one entry, the ISO 8601 interval name=<start>/<end> (stay=2026-11-25/2026-11-27), or an empty value until both ends are chosen. required blocks a native submission with no range and focuses the Trigger; disabled disables the Trigger and submits nothing; readOnly still opens the popup, whose calendar can be browsed but chooses nothing. A form reset returns an uncontrolled picker to its defaultValue.
  • Field: inside a Field, the field's name and disabled win, the Trigger is the labelled element and the focus target, validate receives the range { start, end } (or null), and the hidden input is the validated element. The Trigger is named by the Field's Label, then its own content ("Stay 2026-11-25 – 2026-11-27"); a click on the Label only focuses it. 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-range-picker-triggertoggles the popup, and anchors it
Portalnonemoves the Positioner to the end of body
Positionerdivdate-range-picker-positionerplaces the popup next to the trigger
Popupdivdate-range-picker-popupthe non-modal dialog, holding a RangeCalendar.Root
(hidden input)inputdate-range-picker-inputrendered after the Root's children while it has a name (or a Field's): what the form submits

Usage

import { RangeCalendar } from "@fragiola/primitives-react/range-calendar";
import { DateRangePicker, type DateRange } from "@fragiola/primitives-react/date-range-picker";

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

<DateRangePicker.Root value={value} onValueChange={setValue} locale="en-US">
    <DateRangePicker.Trigger>{value ? format(value) : "Choose dates"}</DateRangePicker.Trigger>
    <DateRangePicker.Portal>
        <DateRangePicker.Positioner sideOffset={4}>
            <DateRangePicker.Popup aria-label="Choose dates">
                <RangeCalendar.Root>
                    {/* its Heading, page buttons and Grid, as on the RangeCalendar page */}
                </RangeCalendar.Root>
            </DateRangePicker.Popup>
        </DateRangePicker.Positioner>
    </DateRangePicker.Portal>
</DateRangePicker.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
valueDateRange | nullthe chosen range, controlled
defaultValueDateRange | nullnullthe initial range, uncontrolled
onValueChange(value: DateRange | 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 range 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 range
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 RangeCalendar page; choosing the range's end 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-range-pickerDateRangePicker, Align, CalendarOptions, ChangeDetails, ChangeReason, DatePickerPopupProps, DatePickerPopupState, DatePickerPortalProps, DatePickerPositionerProps, DatePickerPositionerState, DatePickerRootSharedProps, DatePickerTriggerProps, DatePickerTriggerState, DateRange, DateRangePickerRootProps, PlainDate, PositionerProps, RenderProp, Side, OpenChangeDetails, OverlayActions, OverlayPortalProps, OverlayRootProps
@fragiola/primitives-vue/date-range-pickerDateRangePicker, Align, CalendarOptions, ChangeDetails, ChangeReason, DatePickerPopupProps, DatePickerPopupState, DatePickerPortalProps, DatePickerFormProps, DatePickerPositionerState, DatePickerRootSharedProps, DatePickerTriggerProps, DatePickerTriggerState, DateRange, DateRangePickerRootEmits, DateRangePickerRootProps, PlainDate, PositionerProps, RenderSlotProps, Side, OpenChangeDetails, OverlayActions, OverlayPortalProps, OverlayRootEmits, OverlayRootProps
@fragiola/primitives-angular/date-range-pickerDateRangePickerRoot, Align, CalendarOptions, ChangeDetails, ChangeReason, DatePickerPopup, DatePickerPopupState, DatePickerPortal, DatePickerPositioner, DatePickerPositionerState, DatePickerTrigger, DatePickerTriggerState, DateRange, injectDatePicker, OpenChangeEvent, PlainDate, Side, ValueChangeEvent, OpenChangeDetails, OverlayActions, OverlayPortalOptions