DatePicker Component - Usage Guide

✨ Features

The DatePicker component is a fully-featured calendar picker with:
  • Calendar Grid View - Visual date selection
  • Month/Year Picker - Quick navigation to any month/year
  • Range Selection - Select date ranges
  • Min/Max Dates - Restrict selectable dates
  • Disabled Dates - Custom disabled dates
  • Highlighted Dates - Mark special dates (holidays, events)
  • Popover API - Native browser positioning
  • Anchor Positioning - Auto-flip based on viewport space
  • Smooth Animations - Enter/exit transitions
  • Fully Accessible - Keyboard navigation, ARIA labels

📖 Basic Usage

Single Date Selection

Date Range Selection

With Min/Max Dates

With Disabled Dates

With Highlighted Dates (Holidays)

🎨 UI Views

Calendar View (Default)

  • Month/year header with navigation arrows
  • 7-column grid (Sun-Sat)
  • Click on month/year to switch to month picker
  • Click date to select

Month/Year Picker

  • Year input field
  • 3x4 grid of month buttons
  • Selected month is highlighted
  • Click month to return to calendar view

🎯 Props API

💡 Tips

Working with ISO Dates

The component uses ISO date strings (YYYY-MM-DD):

Generating Disabled Dates

Company Holidays

🎬 Animations

The DatePicker includes smooth transitions:
  • Opening: Fade in + slide down + scale up (200ms)
  • Closing: Fade out + slide up + scale down (200ms)
  • Uses transition-behavior: allow-discrete for complete exit animation

🔧 Styling

The component uses glassmorphism design:

Custom Styling

🚀 Best Practices

  1. Always provide a label for accessibility
  2. Use min/max dates to prevent invalid selections
  3. Highlight important dates like holidays and events
  4. For ranges, provide clear visual feedback
  5. Disable past dates for future-only selections:

✅ Complete Example: Leave Request Form

This creates a fully-featured leave request date picker! 🎉