8000
Skip to content

Repository files navigation

hcg-date-picker

Vanilla JavaScript date picker with calendar, date range (hover preview), multiple dates, event labels, time, and datetime modes. Zero dependencies.

hcg-date-picker calendar, range, and time modes

Features

  • Zero dependencies: one JavaScript file and a companion CSS stylesheet
  • Single date, date range with hover preview, multiple dates, month-only, year-only, time-only, and datetime modes
  • Calendar events map for labels under day numbers (ticket prices, holidays, and more)
  • Click the month/year title to jump months and years (fast birth-date selection)
  • minDate, maxDate, disabledDates, enabledDates, inline calendar
  • Keyboard support (arrows, Enter, Escape)
  • open(), close(), setDate(), clear(), destroy(), and more
  • TypeScript definitions and React wrapper included

Demo

Use the Documentation & demo link above for the live interactive demo on the website.

After cloning this repository, open index.html in your browser for a local demo.

Installation

Download

<link rel="stylesheet" href="hcg-date-picker.css">
<script src="hcg-date-picker.js"></script>

npm

npm install hcg-date-picker
import hcgDatePicker from "hcg-date-picker";
import "hcg-date-picker/hcg-date-picker.css";

CDN

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hcg-date-picker@1/hcg-date-picker.css">
<script src="https://cdn.jsdelivr.net/npm/hcg-date-picker@1/hcg-date-picker.js"></script>

Quick start

Pass options in JavaScript when you create the picker (there is no data-attribute configuration).

<link rel="stylesheet" href="hcg-date-picker.css">
<input type="text" id="birthday" placeholder="Date of birth" readonly>

<script src="hcg-date-picker.js"></script>
<script>
  const picker = hcgDatePicker("#birthday", {
    onChange: (dates, formatted) => console.log(formatted),
  });
</script>

Click the header title (for example July 2026) to open the month grid, click the year to open the year grid, pick a year, then a month, then a day.

API helpers

hcgDatePicker.get("#birthday");
hcgDatePicker.destroy("#birthday");
hcgDatePicker.reset("#birthday");
hcgDatePicker.destroyAll();
console.log(hcgDatePicker.version);

More documentation

Full API reference, live demos, options tables, React notes, and styling guide:

www.html-code-generator.com/javascript/date-picker-library

License

MIT

About

Lightweight dependency-free JavaScript date picker: single, range, multiple, month/year, time, datetime, events, min/max, and TypeScript types.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0