Data inputExtension
Date Picker
A typed DD/MM/YYYY date field with a calendar popup, backed by a native date input.
| Class name | Type | Description |
|---|---|---|
date-pickerplf:date-picker | Component | Wraps the native field and the hidden controls |
date-picker-inputsplf:date-picker-inputs | Part | The row of native start and end fields |
date-picker-fieldplf:date-picker-field | Part | A field that fills its row |
date-picker-controlsplf:date-picker-controls | Part | The hidden controls the script shows |
date-picker-triggerplf:date-picker-trigger | Part | A button trigger, in place of a typed field |
date-picker-errorplf:date-picker-error | Part | A typed field's error the script adds |
date-picker-panelplf:date-picker-panel | Part | The Popover panel |
date-picker-bodyplf:date-picker-body | Part | The range panel's presets and calendar |
date-picker-presetsplf:date-picker-presets | Part | The preset buttons |
date-picker-preset-fieldplf:date-picker-preset-field | Part | The preset select's field the script adds below the md breakpoint, or one the page writes |
date-picker-footerplf:date-picker-footer | Part | The panel's buttons |
date-picker-summaryplf:date-picker-summary | Part | The footer text that shows the draft |
date-picker-panel-rangeplf:date-picker-panel-range | Modifier | The wider range panel, as in Date Range Picker |
Default
Leave the text input unnamed: only the native input’s YYYY-MM-DD value is submitted.
<div class="date-picker" data-plf-date-picker>
<label class="field" for="delivery-date">
<span class="field-label">Delivery date</span>
<input class="input" id="delivery-date" name="delivery-date" type="date" value="2026-10-04" min="2026-01-01" max="2027-12-31">
</label>
<div class="date-picker-controls" hidden>
<div class="popover" data-plf-popover data-plf-align="start">
<div class="field date-picker-field">
<label class="field-label" for="delivery-date-text">Delivery date</label>
<div class="input-group">
<button type="button" class="input-group-action input-group-addon" aria-label="Open calendar"></button>
<input class="input-group-control" type="text" id="delivery-date-text">
</div>
</div>
<div class="popover-content date-picker-panel" aria-label="Choose delivery date" hidden>
<div class="calendar" data-plf-calendar data-plf-today="2026-10-04" data-plf-disabled-dates="2026-10-13"></div>
<div class="date-picker-footer">
<button type="button" class="btn btn-ghost btn-sm" data-plf-popover-close>Cancel</button>
<button type="button" class="btn btn-outline btn-sm" data-plf-date-picker-clear>Clear</button>
</div>
</div>
</div>
</div>
</div><div class="plf:date-picker" data-plf-date-picker>
<label class="plf:field" for="delivery-date">
<span class="plf:field-label">Delivery date</span>
<input class="plf:input" id="delivery-date" name="delivery-date" type="date" value="2026-10-04" min="2026-01-01" max="2027-12-31">
</label>
<div class="plf:date-picker-controls" hidden>
<div class="plf:popover" data-plf-popover data-plf-align="start">
<div class="plf:field plf:date-picker-field">
<label class="plf:field-label" for="delivery-date-text">Delivery date</label>
<div class="plf:input-group">
<button type="button" class="plf:input-group-action plf:input-group-addon" aria-label="Open calendar"></button>
<input class="plf:input-group-control" type="text" id="delivery-date-text">
</div>
</div>
<div class="plf:popover-content plf:date-picker-panel" aria-label="Choose delivery date" hidden>
<div class="plf:calendar" data-plf-calendar data-plf-today="2026-10-04" data-plf-disabled-dates="2026-10-13"></div>
<div class="plf:date-picker-footer">
<button type="button" class="plf:btn plf:btn-ghost plf:btn-sm" data-plf-popover-close>Cancel</button>
<button type="button" class="plf:btn plf:btn-outline plf:btn-sm" data-plf-date-picker-clear>Clear</button>
</div>
</div>
</div>
</div>
</div>JavaScript
Date Picker needs JavaScript and is an extension: the Full script and Full CSS leave it out. 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="core/pelatform-ui-core.min.css">
<link rel="stylesheet" href="components/button.min.css">
<link rel="stylesheet" href="components/form.min.css">
<link rel="stylesheet" href="components/popover.min.css">
<link rel="stylesheet" href="components/select.min.css">
<link rel="stylesheet" href="extensions/calendar.min.css">
<link rel="stylesheet" href="extensions/date-picker.min.css">
<script src="core/pelatform-ui-core.min.js" defer></script>
<script src="components/popover.min.js" defer></script>
<script src="components/select.min.js" defer></script>
<script src="extensions/calendar.min.js" defer></script>
<script src="extensions/date-picker.min.js" defer></script>
<script>document.addEventListener('DOMContentLoaded', () => PLF.init());</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><link rel="stylesheet" href="core/pelatform-ui-core.prefixed.min.css">
<link rel="stylesheet" href="components/button.prefixed.min.css">
<link rel="stylesheet" href="components/form.prefixed.min.css">
<link rel="stylesheet" href="components/popover.prefixed.min.css">
<link rel="stylesheet" href="components/select.prefixed.min.css">
<link rel="stylesheet" href="extensions/calendar.prefixed.min.css">
<link rel="stylesheet" href="extensions/date-picker.prefixed.min.css">
<script src="core/pelatform-ui-core.min.js" defer></script>
<script src="components/popover.min.js" defer></script>
<script src="components/select.min.js" defer></script>
<script src="extensions/calendar.min.js" defer></script>
<script src="extensions/date-picker.min.js" defer></script>
<script>document.addEventListener('DOMContentLoaded', () => PLF.init());</script>With ESM imports, import DatePicker from @pelatform/ui/extensions/date-picker and call use(DatePicker) before init().
Hooks
| Attribute | Purpose |
|---|---|
data-plf-date-picker |
The date-picker container |
data-plf-mode |
single (default) or range, as in Date Range Picker |
<input type="date"> |
The named native input, outside the Popover; its field, the container’s child around it, 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 the text field: an unnamed, labeled text input for DD/MM/YYYY, beside the button in one group such as an Input Group. Unless written, the script gives it that placeholder, a numeric keyboard and no autofill |
data-plf-date-picker-label |
Optional; a span inside a button trigger that shows the chosen date, used instead of a typed field |
data-plf-date-picker-clear |
A button in the panel that clears the date |
Calendar attributes such as data-plf-disabled-dates go on the nested calendar, and the Popover hooks work as in Popover.
Methods
| Method | Behavior |
|---|---|
PLF. |
Returns the instance, creating it for valid markup; options (month, monthCount, locale, weekStartsOn, min, max, disabledDates, today) are passed to the Calendar it creates |
PLF. |
Returns the instance or null |
instance. |
Returns {mode, value, draft, open} |
instance. |
Accepts a date or null; returns false when invalid, unchanged or canceled |
instance., instance. |
Open or close the calendar; return false when nothing changes |
instance. |
Clears the accepted value |
instance. |
Restores the native field; the value stays |
| Event | When |
|---|---|
plf: |
Before a new value is accepted; cancelable |
plf: |
After the native input has the new value |
Each event’s detail:
| Property | Value |
|---|---|
instance |
The Date Picker instance |
trigger |
The control used, such as a day in the calendar or the Clear button, or null from a method |
reason |
trigger, api, or the Calendar’s reason, such as select |
previousState |
The state before the change, shaped like getState |
state |
The state after the change |
Opening and closing fire the Popover events.
Keyboard
| Key | Action |
|---|---|
| Enter | In the field, applies the typed date, as leaving the field does |
| Alt + Down Arrow | In the field, opens the calendar and moves focus into it |
| Escape | Discards unfinished typing and closes the calendar |
| Arrow keys, Home, End, Page Up, Page Down | In the calendar, as in Calendar |
CSS variables
The calendar uses the Calendar variables.
| Variable | Default |
|---|---|
--plf-date-picker-width |
20rem (320px); 48rem (768px) in range mode |
--plf-date-picker-border |
--plf-popover-border, otherwise --plf-color-border-subtle |