Skip to main content

API reference

Modes​

Set with the mode attribute/property: single (default), range, or multiple.

Attributes & properties​

Every attribute has a matching reflected property (e.g. el.value, el.enableTime).

AttributePropertyTypeApplies toDescription
valuevalueISO date, datetime, or comma listsingle, multipleSelected date; datetime when time enabled; comma-separated list in multiple mode.
startstartISO daterangeRange start.
endendISO daterangeRange end.
modemodesingle | range | multipleallSelection mode.
minminISO dateallEarliest selectable date.
maxmaxISO dateallLatest selectable date.
disabled-weekdaysdisabledWeekdayscomma list (0=Sun..6=Sat, UTC)allDisabled weekdays.
enable-timeenableTimebooleansingleShow the time picker.
time-formattimeFormat12 | 24singleTime display format.
dirdirltr | rtlallText direction.
primaryprimaryhijri | gregorianallWhich day number is prominent in cells (default hijri).
secondary-positionsecondaryPositionend | start | above | below | hiddenallWhere the secondary number sits (default below), or hide it.

When the Gregorian month changes inside the grid, the first of the month is labelled with its abbreviated name (e.g. "1 Apr").

isDateDisabled (property only)​

el.isDateDisabled = (hijri, gregorian) => gregorian.getUTCDay() === 5; // disable Fridays

Events​

The element fires a change CustomEvent whose detail depends on the mode:

// single
{ mode: "single"; hijri: HijriDate; gregorian: string; time?: { hour: number; minute: number } }
// range
{ mode: "range"; start: { hijri; gregorian } | null; end: { hijri; gregorian } | null }
// multiple
{ mode: "multiple"; hijri: HijriDate[]; gregorian: string[] }

Theming​

Style via CSS custom properties on the host:

VariablePurpose
--dtp-bgCalendar background.
--dtp-fgForeground text.
--dtp-mutedMuted / secondary text.
--dtp-accentSelection / range accent.
--dtp-accent-fgText on accent.
--dtp-radiusCorner radius.

::part() hooks: day, day-primary, day-secondary, nav-prev, nav-next, time.

hijri-datepicker {
--dtp-accent: #7c3aed;
}
hijri-datepicker::part(day) {
font-weight: 600;
}