ScriptsJun 3, 2026·3 min read

Flatpickr — Lightweight DateTime Picker with No Dependencies

A lightweight, dependency-free datetime picker that provides date, time, and range selection with localization support, mobile-friendly design, and extensive configuration options.

Agent ready

Ready-to-run agent install

This asset can be installed after the agent chooses its runtime, checks the plan, and runs the matching command.

Native · 98/100Policy: allow
Agent surface
Any MCP/CLI agent
Kind
Skill
Install
Single
Trust
Trust: Established
Entrypoint
Flatpickr Overview
Direct install command
npx -y tokrepo@latest install d8fee6e4-5ee2-11f1-9bc6-00163e2b0d79 --target codex

Run after dry-run confirms the install plan.

Introduction

Flatpickr is a lightweight datetime picker that works without any external dependencies. It supports date selection, time picking, date ranges, and multiple date selection with a clean UI that is touch-friendly and accessible. At under 6 KB gzipped, it provides extensive functionality while keeping bundle size small.

What Flatpickr Does

  • Renders an interactive calendar dropdown for date selection on any input element
  • Supports time picking, date ranges, and multi-date selection through configuration flags
  • Provides over 60 locale files for internationalized date formatting and calendar display
  • Allows disabling specific dates, date ranges, or weekdays for scheduling applications
  • Works with form libraries and frameworks through native input element binding

Architecture Overview

Flatpickr creates a calendar DOM element that is positioned relative to the bound input. All date calculations use the native JavaScript Date object without external date libraries. The picker maintains internal state for the current view (days, months, years), selected dates, and configuration. Plugins extend functionality by hooking into lifecycle events (onChange, onOpen, onClose). The CSS is modular, with a base theme and optional theme overrides.

Self-Hosting & Configuration

  • Install via npm, Yarn, or include from a CDN (both JS and CSS files)
  • Bind to an input element with flatpickr(selector, options) or use the data-flatpickr attribute for declarative setup
  • Set mode to "single", "multiple", or "range" to control selection behavior
  • Import locale files to display the calendar in different languages: import { French } from "flatpickr/dist/l10n/fr.js"
  • Apply themes by importing alternative CSS files (dark, material, airbnb) or write custom styles

Key Features

  • Zero dependencies and under 6 KB gzipped for fast page loads
  • Date range selection mode with visual highlighting between start and end dates
  • Plugins system for extras like month select, week select, confirm button, and scroll-based input
  • Mobile-friendly with an option to fall back to native date inputs on touch devices
  • Hooks and callbacks (onChange, onOpen, onClose, onReady) for custom logic integration

Comparison with Similar Tools

  • Pikaday — another lightweight date picker but lacks time selection and range mode; Flatpickr covers more use cases
  • date-fns/date picker libraries — React/Vue date pickers built on date-fns provide deeper framework integration; Flatpickr is framework-agnostic
  • Air Datepicker — jQuery-based date picker with similar features; Flatpickr has no jQuery dependency and a smaller footprint
  • Litepicker — modern lightweight range picker with no dependencies; Flatpickr offers more features (time, multi-select, plugins)
  • Native HTML date input — built into browsers but offers no customization of appearance or behavior; Flatpickr provides a consistent cross-browser experience

FAQ

Q: Does Flatpickr work with React or Vue? A: Yes. Community wrappers like react-flatpickr and vue-flatpickr-component provide idiomatic bindings. You can also initialize Flatpickr on a ref in lifecycle hooks.

Q: How do I disable specific dates? A: Use the disable option with an array of date strings, Date objects, or a function that returns true for dates that should be disabled.

Q: Can Flatpickr handle timezones? A: Flatpickr works with local dates by default. For timezone-aware behavior, parse and format dates using a library like date-fns-tz or Luxon before passing them to Flatpickr.

Q: Is Flatpickr still maintained? A: The library is stable and continues to receive community contributions. Its small scope and zero-dependency design mean it requires minimal ongoing maintenance.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets