npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@mbanda1/date-picker

v0.3.3

Published

Date picker build with react

Readme

@mbanda1/datepicker

Accessible Chakra UI date pickers for single dates and ranges, built with React, React Hook Form 7, and date-fns. Every component ships fully typed and themable.

Features

  • Chakra-first API that plays nicely with your design tokens.
  • Controlled single-date picker with optional time selection.
  • Built-in React Hook Form 7 wrapper for effortless validation.
  • Date-range picker with sticky action bar and optional preset column.
  • Tree-shakeable TypeScript build (cjs, esm, and d.ts).

Installation

pnpm add @mbanda1/datepicker
# or
npm install @mbanda1/datepicker

Peer dependencies:

  • react >= 17, react-dom >= 17
  • @chakra-ui/react >= 1.0.3
  • framer-motion and @emotion/* (required by Chakra)
  • react-hook-form >= 7 (only if you use the hook-form wrapper)

Quick Start

Basic date picker

Single date picker screenshot showing date and time selection

import { useState } from 'react';
import { DatePickerInput } from '@mbanda1/datepicker';

export function EventDateField() {
  const [date, setDate] = useState<Date | null>(null);

  return (
    <DatePickerInput
      value={date}
      onChange={setDate}
      placeholder='Select a date'
      dateFormat='MMMM d, yyyy'
      minDate={new Date()}
      showTimeSelect
      timeInterval={60}
      minTime='09:00'
      maxTime='18:00'
    />
  );
}

React Hook Form 7 integration

import { useForm } from 'react-hook-form';

type FormValues = { eventDate: Date | null };

export function BookingForm() {
  const {
    handleSubmit,
    control,
    formState: { errors },
  } = useForm<FormValues>({ defaultValues: { eventDate: null } });

  return (
    <form onSubmit={handleSubmit(console.log)}>
      
        <Controller
    control={control}
    name='date'
    render={({ field }) => (
      <DatePickerInput
        {...field}
        placeholder='Select a date'
        dateFormat='MMMM d, yyyy'
      />
    )}
  />
    </form>
  );
}

Date range picker

Date range picker screenshot

import { useState } from 'react';
import { DateRangePickerInput } from '@mbanda1/datepicker';

export function RangeFilter() {
  const [range, setRange] = useState<{ startDate: Date | null; endDate: Date | null }>({
    startDate: null,
    endDate: null,
  });

  return (
      <DateRangePickerInput
      startDate={range.startDate}
      endDate={range.endDate}
      onChange={setRange}
      dateFormat='yyyy-MM-dd'
      placeholder='Select period'
      showPresets
      clearInput={() => setRange({ startDate: null, endDate: null })}
    />
  );
}

Need the range picker in React Hook Form? Wrap DateRangePickerInput in a Controller and forward value/onChange manually (see "Range picker + RHF" below).

API Reference

DatePickerInput

| Prop | Type | Default | Description | | --- | --- | --- | --- | | value | Date \| null | undefined | Controlled value. | | onChange | (date: Date \| null) => void | undefined | Fires with the selected date or null. | | defaultValue | Date | new Date() | Starting date when no value is supplied. | | minDate / maxDate | Date | undefined | Bounds selection (inclusive, normalized to start/end of day). | | placeholder | string | 'Select date' | Input placeholder. | | dateFormat | string | 'yyyy-MM-dd' | date-fns compatible format string. | | showTodayButton | boolean | true | Toggles the "Today" shortcut. | | showTimeSelect | boolean | false | Enables the time list beneath the calendar. | | timeInterval | number | 30 | Minutes between time options. | | minTime / maxTime | string (HH:mm) | '00:00' / '23:59' | Bounds the selectable time window. | | isDisabled / isRequired / isInvalid | boolean | false | Chakra input states. | | size | 'sm' \| 'md' \| 'lg' | 'md' | Chakra input size. | | variant | 'outline' \| 'filled' \| 'flushed' \| 'unstyled' | 'outline' | Chakra input variant. | | showClearIcon | boolean | true | Display the inline clear control. | | clearInput | () => void | undefined | Notified when the clear icon is clicked. |

DateRangePickerInput

| Prop | Type | Default | Description | | --- | --- | --- | --- | | startDate / endDate | Date \| null | undefined | Controlled range values. | | onChange | (range: { startDate: Date \| null; endDate: Date \| null }) => void | undefined | Receives local selections when Apply is clicked or when cleared. | | defaultStartDate | Date | new Date() | Initial month focus if no startDate. | | minDate / maxDate | Date | undefined | Bounds both calendars. | | placeholder | string | 'Select date range...' | Input placeholder. | | dateFormat | string | 'yyyy MMM d' | Format applied to both dates. | | isDisabled / isRequired / isInvalid | boolean | false | Chakra input states. | | size | 'sm' \| 'md' \| 'lg' | 'md' | Chakra input size. | | variant | 'outline' \| 'filled' \| 'flushed' \| 'unstyled' | 'outline' | Chakra input variant. | | showClearIcon | boolean | true | Display the inline clear control. | | clearInput | () => void | undefined | Called when the user clears the selection. | | showPresets | boolean | false | Adds the preset column on the left. | | isLoading | boolean | false | Disables the Apply button while loading. |

Range picker + React Hook Form (manual)

<Controller
  name='dateRange'
  control={control}
  render={({ field: { value, onChange } }) => (
    <DateRangePickerInput
      startDate={value?.startDate ?? null}
      endDate={value?.endDate ?? null}
      onChange={onChange}
      showPresets
    />
  )}
/>;

License

MIT © mbanda1