Data inputExtension

Date Range Picker

A typed start and end date field with presets and a two-month calendar, backed by two native date inputs.

Class nameTypeDescription
date-pickerplf:date-pickerComponentA Date Picker in range mode
calendarplf:calendarComponentThe range calendar
date-picker-inputsplf:date-picker-inputsPartThe row of native start and end fields
date-picker-fieldplf:date-picker-fieldPartA field that fills its row
date-picker-controlsplf:date-picker-controlsPartThe hidden controls the script shows
date-picker-panelplf:date-picker-panelPartThe Popover panel
date-picker-bodyplf:date-picker-bodyPartThe presets and calendar
date-picker-presetsplf:date-picker-presetsPartThe preset buttons
date-picker-preset-fieldplf:date-picker-preset-fieldPartThe preset select's field the script adds below the md breakpoint, or one the page writes
date-picker-footerplf:date-picker-footerPartThe panel's buttons
date-picker-summaryplf:date-picker-summaryPartThe footer text that shows the draft
date-picker-panel-rangeplf:date-picker-panel-rangeModifierThe wider range panel

Default

Give both native inputs the same min and max.

Nights

The script counts the nights from plf:date-picker:change, as a booking form does.

Choose your check-in and check-out dates.

JavaScript

Date Range Picker is the range mode of the Date Picker extension, with the same methods, events and keys and a {start, end} value; calendar edits fire the Calendar events until Apply. The Full script (pelatform-ui.min.js) and the extension scripts after it start every component on page load, with no code of your own; with Core and single files, the last line starts them. For markup you add later, see Dynamic content.

<link rel="stylesheet" href="pelatform-ui.min.css">
<link rel="stylesheet" href="extensions/calendar.min.css">
<link rel="stylesheet" href="extensions/date-picker.min.css">
<script src="pelatform-ui.min.js" defer></script>
<script src="extensions/calendar.min.js" defer></script>
<script src="extensions/date-picker.min.js" defer></script>
<link rel="stylesheet" href="pelatform-ui.prefixed.min.css">
<link rel="stylesheet" href="extensions/calendar.prefixed.min.css">
<link rel="stylesheet" href="extensions/date-picker.prefixed.min.css">
<script src="pelatform-ui.min.js" defer></script>
<script src="extensions/calendar.min.js" defer></script>
<script src="extensions/date-picker.min.js" defer></script>

Hooks

These hooks add to or replace the Date Picker hooks.

Attribute Purpose
data-plf-mode="range" On the container; the nested calendar inherits it and shows two months, one below the md breakpoint
<input type="date"> Two named native inputs outside the Popover, the start and then the end, with the same min and max; their wrapper, the container’s child around them, hides once the text field works
data-plf-popover Holds the field, its first child, and the panel, written hidden. The field holds the calendar button, the Popover’s trigger, and one unnamed, labeled text input for DD/MM/YYYY – DD/MM/YYYY, or one for each date. Unless written, the script gives it that placeholder and no autofill
data-plf-date-picker-apply Required; the button that accepts the draft of calendar clicks and presets. Cancel keeps the accepted dates
data-plf-date-picker-preset Optional buttons: today, yesterday, last-7-days, last-30-days, this-month or last-month, counted from the calendar’s today
data-plf-preset-label, data-plf-custom-label On the container: the label of the preset select the script adds from the buttons, shown instead of them below the md breakpoint, and its first option; Quick range and Custom range by default. A <select> written in the panel with one empty option and the preset values replaces it
data-plf-date-picker-summary Optional footer text that shows the draft; its own text shows when empty

CSS variables

The panel also uses the Date Picker variables.

Variable Default
--plf-date-picker-width 48rem (768px); 20rem (320px) below the md breakpoint
--plf-date-picker-preset-width 9rem (144px), the preset sidebar

Built with Pelatform UIv0.1.0

Components

Getting started

Foundations

Components

Actions

Data display

Navigation

Feedback

Data input

Layout

Advanced

Integrations

Blocks

Application

Authentication

Icons