Datelite DatePicker Library Examples

Download Back To CSSScript.Com

A feature-rich, high-customizable, fully accessible JavaScript date picker with multiple themes and a powerful API.

Icon Examples

Default Icon (Right)

No date selected

JavaScript Code

const picker = new DatePicker('#icon-right', { // Icon options showIcon: true, iconPosition: 'right', // default // Basic options mode: 'single', format: 'Y-m-d', // Event callback onChange: function(date) { console.log('Selected:', date); } });

Icon on Left

No date selected

JavaScript Code

const picker = new DatePicker('#icon-left', { showIcon: true, iconPosition: 'left', // position on left mode: 'single', format: 'Y-m-d' });

Custom Icon

No date selected

JavaScript Code

const picker = new DatePicker('#custom-icon', { showIcon: true, customIcon: '📅', // emoji or HTML mode: 'single', format: 'Y-m-d' }); // You can also use HTML/SVG: // customIcon: '<i class="fas fa-calendar"></i>'

No Icon

No date selected

JavaScript Code

const picker = new DatePicker('#no-icon', { showIcon: false, // disable icon mode: 'single', format: 'Y-m-d' });

Single Date Selection

Basic Single Date

No date selected

With Time Selection

No date selected

Range Date Selection

Date Range (Auto-close)

Closes automatically after selecting both dates
No range selected

JavaScript Code

const rangePicker = new DatePicker('#range-date', { mode: 'range', // enable range selection format: 'Y-m-d', closeOnSelect: true, // auto-close after both dates onChange: function(dateRange) { if (dateRange.start && dateRange.end) { console.log('Range:', dateRange.start, 'to', dateRange.end); } } });

Range with Confirmation

No range selected

JavaScript Code

const confirmPicker = new DatePicker('#range-confirm', { mode: 'range', confirmRange: true, // show Apply/Cancel buttons applyButtonText: 'Apply', cancelButtonText: 'Cancel', onChange: function(dateRange) { // Only fires when Apply is clicked console.log('Confirmed range:', dateRange); } });

Custom Button Text

No range selected

JavaScript Code

const customPicker = new DatePicker('#range-custom-buttons', { mode: 'range', confirmRange: true, applyButtonText: 'Confirm Selection', // custom text cancelButtonText: 'Reset', // custom text onChange: function(dateRange) { console.log('Custom range:', dateRange); } });

Multiple Date Selection

Multiple Dates

No dates selected

Inline Calendar

Always Visible

No date selected

With Restrictions

No date selected

Month/Year Dropdown Examples

Both Dropdowns

Month Dropdown Only

Year Dropdown Only

Limited Year Range

Icon Control API

Dynamic Icon Control

Use buttons to control icon behavior

Date Blocking Examples

Block Weekends

No date selected

Block Past Dates

No date selected

Block Specific Dates

No date selected

Block Date Ranges

No date selected

Only Specific Days Allowed

No date selected

Custom Block Function

No date selected

Positioning Examples

Append to Body

No date selected

Fixed Position (X: 100, Y: 200)

No date selected

JavaScript Code

const fixedPicker = new DatePicker('#fixed-position', { mode: 'single', // Fixed positioning positionX: 100, // 100px from left positionY: 200, // 200px from top format: 'Y-m-d' }); // Dynamic positioning fixedPicker.setPosition(300, 400); // change position fixedPicker.resetPosition(); // back to auto

Custom Container

Custom Container (datepicker will appear here)
No date selected

Custom Container

Custom Container (datepicker will appear here)
No date selected

With Offset (X: +50, Y: +20)

No date selected

CSS Customization Examples

Green Theme

No date selected

CSS Customization

/* CSS Variables Override */ .datepicker-container.green-theme { --dp-primary-color: #28a745; --dp-primary-hover: #218838; --dp-primary-light: #d4edda; --dp-border-focus: #28a745; } /* JavaScript */ const picker = new DatePicker('#green-theme', { theme: 'green-theme' });

Purple Theme

No date selected

CSS Variables

.datepicker-container.purple-theme { --dp-primary-color: #6f42c1; --dp-primary-hover: #5a32a3; --dp-primary-light: #e2d9f3; } /* Available Variables: */ /* --dp-day-size: 36px */ /* --dp-border-radius-md: 6px */ /* --dp-font-size-base: 14px */ /* --dp-spacing-lg: 16px */

Large Size Theme

No date selected

Size Customization

.datepicker-container.large-theme { --dp-day-size: 48px; --dp-button-height: 40px; --dp-font-size-base: 16px; --dp-font-size-lg: 18px; --dp-container-min-width: 320px; } /* All 50+ CSS variables available for customization */

Position Control API

Dynamic Position Control

Use buttons to control positioning

Date Blocking Control API

Dynamic Date Blocking Control

Use buttons to control date blocking

Range Confirmation Control API

Dynamic Range Confirmation Control

Use buttons to control range confirmation

Dropdown Control API

Dynamic Dropdown Control

API Methods Demonstration

Programmatic Control

Use the buttons above to test API methods