Overview
The DatePicker component provides a comprehensive calendar interface for selecting dates. It supports both single date selection and date range selection modes, with keyboard navigation and accessibility features.Component Selector
Basic Usage
Date Range Selection
With Min/Max Dates
Properties
Placeholder text displayed when no date is selected
When true, prevents user interaction with the date picker
Minimum selectable date. Dates before this will be disabled
Maximum selectable date. Dates after this will be disabled
Selection mode:
single: Select a single daterange: Select a date range (start and end dates)
Events
Emitted when a date or date range is selected. Returns a single
Date in single mode or Date[] in range modeForm Integration
The DatePicker component implements
ControlValueAccessor and works seamlessly with Angular forms.Reactive Forms
Template-Driven Forms
Keyboard Navigation
The DatePicker supports comprehensive keyboard navigation:| Key | Action |
|---|---|
Enter / Space | Open/close the calendar, or select the active date |
Escape | Close the calendar |
Arrow Keys | Navigate between dates in the calendar |
Home | Move to the start of the week |
End | Move to the end of the week |
Page Up | Move to the previous month |
Page Down | Move to the next month |
Arrow Down (when closed) | Open the calendar |
Accessibility Features
- Full ARIA support with proper roles and labels
- Keyboard navigation for date selection
- Screen reader announcements for date navigation
- Focus management between trigger and calendar
- Disabled state handling
Value Format
The component accepts and returns:- Single mode:
Dateobject ornull - Range mode:
Date[]array with 1-2 elements, ornull- One element: Start date selected, end date pending
- Two elements: Complete date range
[startDate, endDate]
Styling
The DatePicker uses the selectormagary-datepicker and includes the following CSS classes:
.magary-datepicker: Main container.magary-datepicker-trigger: The input trigger button.magary-datepicker-panel: The calendar dropdown panel.magary-datepicker-calendar: Calendar grid container.magary-datepicker-day: Individual day cells.selected: Applied to selected dates.today: Applied to today’s date.disabled: Applied to disabled dates
