Skip to main content

duck calendar

Headless, framework-agnostic calendar engine with date adapter pattern, React hooks, and compound components.

Loading diagram...

Benchmarks

Built to replace react-day-picker. The measurements:

~5 KB gzipped. Zero dependencies. 4 calendar systems. 7 date adapters. Full keyboard navigation and WAI-ARIA grid pattern. Islamic, Persian, and Hebrew support at this size. See the full benchmarks and the comparison with react-day-picker.

The four layers

Core - Pure functions for grid building, selection logic, and navigation. No React, no state, no side effects.

Adapter - An Adapter.IDateAdapter<TDate> interface that abstracts date operations. Ships with a zero-dependency NativeAdapter for Date. Plug in dayjs, date-fns, or Temporal when you need it.

React hooks - useCalendar, useTimePicker, useDateTime manage state and return prop getters you spread onto your elements.

Compound components - Available in @gentleduck/primitives/calendar when you want them. The hooks are first-class.


Design goals

Existing React calendar libraries bundle CSS, mandate a specific date library, or ship monolithic components you cannot tree-shake. @gentleduck/calendar addresses each:

  • ~5 KB gzipped - 3 to 9 times smaller than the alternatives tested.
  • Zero runtime dependencies - NativeAdapter uses Date and Intl.DateTimeFormat.
  • Pluggable date backend - swap Date for dayjs, date-fns, or Temporal without touching calendar code.
  • No CSS - style with data attributes and Tailwind.
  • WAI-ARIA grid pattern - keyboard navigation and screen reader announcements built in.

What's in the package

ExportDescription
NativeAdapterZero-dep adapter for the native Date object
buildCalendarMonthBuild a single month grid
buildMultiMonthBuild multiple consecutive month grids
buildCalendarYearBuild a 12-month picker
buildDecadeViewBuild a decade year picker
selectDayCompute new selection value
applySelectionDecorate weeks with selection flags
navigate / canNavigateNavigate and check bounds
useCalendarMain calendar React hook
useTimePickerTime picker React hook
useDateTimeCombined date+time React hook

Next pages