Calendar
🚧

Under Construction This component is a work-in-progress.

Calendar

Calendar is a primitive to be used by the Date Pick component. Displays an interactive calendar.


Current Status

  • Built with date-fns, Radix UI Select, and Tailwind CSS
  • Intended to be used within the Date Pick component

Future

  • Add animations
  • Improve responsive design for all common device sizes
  • Add darkmode support
  • Standardize color design token

Examples

TBD

How to use

Install date-fns library

npm install date-fns

It's used for date formatting.

Install Radix UI Select

npm install @radix-ui/react-select

Used to build the year dropdown.

Create component

Copy the code from the sandbox above and paste it into a new file (e.g. Calendar.tsx)

Use it with Date Pick

Import it into Date Pick

Component API

Required PropTypeDescription
namestringDate Pick's input name
startYearRangeNumberSets earliest year in Date Pick's Calendar
endYearRangeNumberSets latest year in Date Pick's Calendar
selectedDayDateThe currently selected day.
setSelectedDay(value: Date) => voidUpdates selectedDay
setShowCalendar(value: "CalendarClosed" | "CalendarOpen") => voidDetermines if Date Pick's Accordion should be open/closed. Can't be a boolean to match with Radix UI's props.
handleSelectedDayChange(name: string, selectedDay: Date) => voidHandles logic whenever a Calendar day (aka button) is clicked
Optional PropTypeDescription
defaultValueDatePassed from Field to Date Pick to Calendar. Determines the day the calendar selects by default.