Skip to main content
The Datepicker component provides an intuitive calendar interface for selecting dates with support for single dates, date ranges, and various constraints.

Basic usage

<flx-datepicker
  label="Birth date"
  [(ngModel)]="birthDate">
</flx-datepicker>

Properties

label
string
Label text displayed above the datepicker
placeholder
string
default:"Select date"
Placeholder text when no date is selected
value
Date | DateRange
Selected date or date range
mode
'single' | 'range'
default:"single"
Selection mode: single date or date range
disabled
boolean
default:"false"
Disables the datepicker
required
boolean
default:"false"
Marks the field as required
error
boolean | string
default:"false"
Shows error state
minDate
Date
Minimum selectable date
maxDate
Date
Maximum selectable date
disabledDates
Date[]
Array of dates that cannot be selected
format
string
default:"MM/dd/yyyy"
Date display format
firstDayOfWeek
0-6
default:"0"
First day of week (0 = Sunday, 1 = Monday, etc.)
showClearButton
boolean
default:"true"
Shows button to clear selection

Events

valueChange
EventEmitter<Date | DateRange>
Emitted when the selected date changes
calendarOpen
EventEmitter<void>
Emitted when calendar opens
calendarClose
EventEmitter<void>
Emitted when calendar closes

Examples

<flx-datepicker
  label="Appointment date"
  placeholder="Select a date"
  [(ngModel)]="appointmentDate">
</flx-datepicker>
export class AppointmentForm {
  appointmentDate = new Date();
}

Styling

flx-datepicker {
  --flx-datepicker-input-height: 40px;
  --flx-datepicker-border-radius: 4px;
  --flx-datepicker-border-color: #d1d5db;
  --flx-datepicker-calendar-background: #ffffff;
  --flx-datepicker-day-size: 36px;
  --flx-datepicker-day-border-radius: 50%;
  --flx-datepicker-selected-background: #3b82f6;
  --flx-datepicker-selected-color: #ffffff;
  --flx-datepicker-today-border-color: #3b82f6;
  --flx-datepicker-disabled-color: #9ca3af;
  --flx-datepicker-range-background: #dbeafe;
}

Accessibility

The Datepicker component is fully accessible:
  • Keyboard navigation (Arrow keys, Enter, Escape)
  • role="dialog" for calendar popup
  • aria-label for date buttons
  • Screen reader announcements for date selection
  • Focus management and trapped focus in calendar

Best practices

  • Set appropriate minDate and maxDate constraints
  • Use disabledDates for unavailable dates (holidays, blackout dates)
  • Provide clear labels indicating the expected date format
  • For date ranges, validate that end date is after start date
  • Use consistent date formats across your application
  • Consider timezone implications for date-only selections
When using date ranges, consider setting the minDate of the end date picker to the selected start date to prevent invalid ranges.
  • Input - For manual date entry

Build docs developers (and LLMs) love