Date Range Picker Integrations

TypeScript & ES modules

Import the constructor, stylesheet and option types directly from the package. The picker writes the applied range back to the input.

App source

main.ts
import DateRangePicker, { type Options } from 'daterangepicker';
import 'daterangepicker/daterangepicker.css';

const input = document.querySelector<HTMLInputElement>('#dates')!;
const options: Options = { singleCalendar: true };
new DateRangePicker(input, options);
index.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Report dates</title>
  <link rel="stylesheet" href="../../daterangepicker.css">
  <script type="module" src="../assets/esm.js"></script>
</head>
<body>
  <label>Report dates<input id="dates" type="text"></label>
</body>
</html>
Run this example locally

Serve the website directory over HTTP and open /examples/esm/. To edit the app, change its files in example/integrations/esm and run these commands from example/integrations.

npm ci
npm run build