- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Code Block
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner (Toast)
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
- Trace
Date Picker
A date picker component.
import { Component } from '@angular/core';
import { HlmDatePickerImports } from '@spartan-ng/helm/date-picker';
import { HlmFieldImports } from '@spartan-ng/helm/field';
@Component({
selector: 'spartan-date-picker-preview',
imports: [HlmDatePickerImports, HlmFieldImports],
template: `
<hlm-field>
<label hlmFieldLabel>Date of birth</label>
<hlm-date-picker [minDate]="minDate" [maxDate]="maxDate">
<hlm-date-picker-trigger buttonId="date">Pick a date</hlm-date-picker-trigger>
</hlm-date-picker>
</hlm-field>
`,
})
export class DatePickerPreview {
/** The minimum date */
public minDate = new Date(2023, 0, 1);
/** The maximum date */
public maxDate = new Date(2030, 11, 31);
}Installation
The Date Picker component is built with the Popover and the Calendar components.
ng g @spartan-ng/cli:ui date-pickernx g @spartan-ng/cli:ui date-pickerUsage
import { HlmDatePickerImports } from '@spartan-ng/helm/date-picker';<hlm-date-picker [minDate]="minDate" [maxDate]="maxDate">
<hlm-date-picker-trigger buttonId="date">Pick a date</hlm-date-picker-trigger>
</hlm-date-picker>Examples
Custom Configs
Use provideHlmDatePickerConfig to provide custom configs for the date picker component throughout the application.
autoCloseOnSelect: boolean;iftrue, the date picker will close when a date is selected.formatDate: (date: T) => string;defines the default format how the date should be displayed in the UI.transformDate: (date: T) => T;defines the default format how the date should be transformed before saving to model/form.
import { Component } from '@angular/core';
import { HlmDatePickerImports, provideHlmDatePickerConfig } from '@spartan-ng/helm/date-picker';
import { HlmFieldImports } from '@spartan-ng/helm/field';
import { DateTime } from 'luxon';
@Component({
selector: 'spartan-date-picker-config',
imports: [HlmDatePickerImports, HlmFieldImports],
providers: [
provideHlmDatePickerConfig({
formatDate: (date: Date) => DateTime.fromJSDate(date).toFormat('dd.MM.yyyy'),
transformDate: (date: Date) => DateTime.fromJSDate(date).plus({ days: 1 }).toJSDate(),
}),
],
template: `
<hlm-field>
<label hlmFieldLabel for="date-custom-config">Date Picker with Config</label>
<hlm-date-picker [minDate]="minDate" [maxDate]="maxDate">
<hlm-date-picker-trigger buttonId="date-custom-config">Pick a date</hlm-date-picker-trigger>
</hlm-date-picker>
</hlm-field>
`,
})
export class DatePickerConfigExample {
/** The minimum date */
public minDate = new Date(2023, 0, 1);
/** The maximum date */
public maxDate = new Date(2030, 11, 31);
}Multiple Selection
Use hlm-date-picker-multi for multiple date selection. Limit the selectable dates using minSelection and maxSelection inputs.
import { Component } from '@angular/core';
import { HlmDatePickerImports } from '@spartan-ng/helm/date-picker';
import { HlmFieldImports } from '@spartan-ng/helm/field';
@Component({
selector: 'spartan-date-picker-multiple',
imports: [HlmDatePickerImports, HlmFieldImports],
template: `
<hlm-field>
<label hlmFieldLabel for="date-multi">Date Picker Multiple</label>
<hlm-date-picker-multi
[minDate]="minDate"
[maxDate]="maxDate"
[autoCloseOnMaxSelection]="true"
[minSelection]="2"
[maxSelection]="6"
>
<hlm-date-picker-trigger buttonId="date-multi">Pick dates</hlm-date-picker-trigger>
</hlm-date-picker-multi>
</hlm-field>
`,
})
export class DatePickerMultipleExample {
/** The minimum date */
public minDate = new Date(2023, 0, 1);
/** The maximum date */
public maxDate = new Date(2030, 11, 31);
}Range Picker
Use hlm-date-range-picker for range date selection. Set the range by using startDate and endDate inputs. Use numberOfMonths to display multiple months side by side, or set it globally with provideHlmDateRangePickerConfig .
import { Component } from '@angular/core';
import { HlmDatePickerImports } from '@spartan-ng/helm/date-picker';
import { HlmFieldImports } from '@spartan-ng/helm/field';
@Component({
selector: 'spartan-date-picker-range',
imports: [HlmDatePickerImports, HlmFieldImports],
template: `
<hlm-field>
<label hlmFieldLabel for="date-range-picker">Date Picker Range</label>
<hlm-date-range-picker
[minDate]="minDate"
[maxDate]="maxDate"
[numberOfMonths]="2"
[autoCloseOnEndSelection]="true"
>
<hlm-date-picker-trigger buttonId="date-range-picker">Enter a date range</hlm-date-picker-trigger>
</hlm-date-range-picker>
</hlm-field>
`,
})
export class DatePickerRangeExample {
/** The minimum date */
public minDate = new Date(2023, 0, 1);
/** The maximum date */
public maxDate = new Date(2030, 11, 31);
}Format Date
Use formatDate input to override the global date format for the date picker component.
import { Component } from '@angular/core';
import { HlmDatePickerImports, provideHlmDatePickerConfig } from '@spartan-ng/helm/date-picker';
import { HlmFieldImports } from '@spartan-ng/helm/field';
import { DateTime } from 'luxon';
@Component({
selector: 'spartan-date-picker-format',
imports: [HlmDatePickerImports, HlmFieldImports],
providers: [
// Global formatDate config
provideHlmDatePickerConfig({ formatDate: (date: Date) => DateTime.fromJSDate(date).toFormat('dd.MM.yyyy') }),
],
template: `
<hlm-field>
<label hlmFieldLabel for="date-format">Date Picker with Custom Format</label>
<hlm-date-picker [minDate]="minDate" [maxDate]="maxDate" [formatDate]="formatDate">
<hlm-date-picker-trigger buttonId="date-format">Pick a date</hlm-date-picker-trigger>
</hlm-date-picker>
</hlm-field>
`,
})
export class DatePickerFormatExample {
/** The minimum date */
public minDate = new Date(2023, 0, 1);
/** The maximum date */
public maxDate = new Date(2030, 11, 31);
/** Overrides global formatDate */
public formatDate = (date: Date) => DateTime.fromJSDate(date).toFormat('MMMM dd, yyyy');
}Input Picker
Use hlm-date-picker-input instead of hlm-date-picker-trigger to let users type a date directly. Provide a parseDate input (or set it globally via provideHlmDatePickerConfig ) to control how typed strings are parsed into dates - typically pair it with a matching formatDate .
import { Component } from '@angular/core';
import { HlmDatePickerImports } from '@spartan-ng/helm/date-picker';
import { HlmFieldImports } from '@spartan-ng/helm/field';
import { DateTime } from 'luxon';
@Component({
selector: 'spartan-date-picker-input-example',
imports: [HlmDatePickerImports, HlmFieldImports],
template: `
<hlm-field>
<label hlmFieldLabel for="date-input">Date of birth</label>
<hlm-date-picker
captionLayout="dropdown"
[maxDate]="maxDate"
[defaultFocusedDate]="defaultFocusedDate"
[formatDate]="formatDate"
>
<hlm-date-picker-input
inputId="date-input"
placeholder="dd.MM.yyyy"
[parseDate]="parseDate"
[formatInputDate]="formatInputDate"
/>
</hlm-date-picker>
</hlm-field>
`,
})
export class DatePickerInputExample {
/** The maximum date */
public maxDate = new Date();
/** Open the calendar at "today minus 18 years" - a reasonable anchor for a date-of-birth picker. */
public defaultFocusedDate = DateTime.now().minus({ years: 18 }).toJSDate();
/** Format dates as `dd.MM.yyyy` (e.g. `01.07.2026`). */
public formatDate = (date: Date): string => DateTime.fromJSDate(date).toFormat('dd MMM yyyy');
public formatInputDate = (date: Date): string => DateTime.fromJSDate(date).toFormat('dd.MM.yyyy');
/** Parse `dd.MM.yyyy` strings back into `Date` instances. */
public parseDate = (value: string): Date | null => {
const dt = DateTime.fromFormat(value, 'dd.MM.yyyy');
return dt.isValid ? dt.toJSDate() : null;
};
}Date and Time picker
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmDatePickerImports } from '@spartan-ng/helm/date-picker';
import { HlmFieldImports } from '@spartan-ng/helm/field';
import { HlmInputImports } from '@spartan-ng/helm/input';
@Component({
selector: 'spartan-date-and-time-picker',
imports: [HlmDatePickerImports, HlmFieldImports, HlmInputImports],
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'w-full max-w-xs',
},
template: `
<hlm-field-group class="mx-auto max-w-xs flex-row">
<hlm-field>
<label hlmFieldLabel for="date-picker">Date</label>
<hlm-date-picker [minDate]="minDate" [maxDate]="maxDate">
<hlm-date-picker-trigger buttonId="date-picker">Select date</hlm-date-picker-trigger>
</hlm-date-picker>
</hlm-field>
<hlm-field>
<label hlmFieldLabel for="time-picker">Time</label>
<input
hlmInput
id="time-picker"
type="time"
step="1"
[defaultValue]="'10:30:00'"
class="bg-background appearance-none [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none"
/>
</hlm-field>
</hlm-field-group>
`,
})
export class DateAndTimePickerExample {
/** The minimum date */
public minDate = new Date(2023, 0, 1);
/** The maximum date */
public maxDate = new Date(2030, 11, 31);
}Month Year Picker
import { Component } from '@angular/core';
import { HlmDatePickerImports } from '@spartan-ng/helm/date-picker';
import { HlmFieldImports } from '@spartan-ng/helm/field';
@Component({
selector: 'spartan-date-month-year-picker',
imports: [HlmDatePickerImports, HlmFieldImports],
template: `
<hlm-field>
<label hlmFieldLabel>Month Year Picker</label>
<hlm-month-year-picker [minDate]="minDate" [maxDate]="maxDate" autoCloseOnSelect>
<hlm-date-picker-trigger>Pick a year and month</hlm-date-picker-trigger>
</hlm-month-year-picker>
</hlm-field>
`,
})
export class DatePickerMonthYearExample {
/** The minimum date */
public minDate = new Date(2023, 0, 1);
/** The maximum date */
public maxDate = new Date(2030, 11, 31);
}Form
Sync the date to a form by adding formControlName to hlm-date-picker .
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { form, FormField, FormRoot, required } from '@angular/forms/signals';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmDatePickerImports } from '@spartan-ng/helm/date-picker';
import { HlmFieldImports } from '@spartan-ng/helm/field';
@Component({
selector: 'spartan-date-picker-form',
imports: [HlmDatePickerImports, FormRoot, FormField, HlmButtonImports, HlmFieldImports],
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'w-full max-w-xs',
},
template: `
<form [formRoot]="form">
<hlm-field-group>
<hlm-field>
<label for="date-birthday" hlmFieldLabel>Date of birth</label>
<hlm-date-picker
[minDate]="minDate"
[maxDate]="maxDate"
captionLayout="dropdown"
[formField]="form.birthday"
[autoCloseOnSelect]="true"
>
<hlm-date-picker-trigger buttonId="date-birthday">Pick a date</hlm-date-picker-trigger>
</hlm-date-picker>
<hlm-field-description>Your date of birth is used to calculate your age.</hlm-field-description>
</hlm-field>
<hlm-field orientation="horizontal">
<button type="submit" hlmBtn [disabled]="form().submitting()">Submit</button>
</hlm-field>
</hlm-field-group>
</form>
`,
})
export class DatePickerFormExample {
protected readonly _model = signal<{ birthday: Date | null }>({ birthday: null });
public readonly form = form(
this._model,
(schemaPath) => {
required(schemaPath.birthday, { message: 'Please select a date' });
},
{
submission: {
action: async () => {
const model = this._model();
console.log(model);
},
},
},
);
/** The minimum date */
public minDate = new Date(2023, 0, 1);
/** The maximum date */
public maxDate = new Date(2030, 11, 31);
}Form with Input Picker
Combine formControlName with hlm-date-picker-input to let users type a date or pick one from the calendar while syncing the value to a reactive form.
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { form, FormField, FormRoot, required } from '@angular/forms/signals';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmDatePickerImports } from '@spartan-ng/helm/date-picker';
import { HlmFieldImports } from '@spartan-ng/helm/field';
import { DateTime } from 'luxon';
@Component({
selector: 'spartan-date-picker-form-input',
imports: [FormRoot, FormField, HlmDatePickerImports, HlmButtonImports, HlmFieldImports],
changeDetection: ChangeDetectionStrategy.OnPush,
host: { class: 'w-full max-w-xs' },
template: `
<form [formRoot]="form">
<hlm-field-group>
<hlm-field>
<label for="date-birthday-input" hlmFieldLabel>Date of birth</label>
<hlm-date-picker
captionLayout="dropdown"
[formField]="form.birthday"
[maxDate]="maxDate"
[defaultFocusedDate]="defaultFocusedDate"
[formatDate]="formatDate"
>
<hlm-date-picker-input
inputId="date-birthday-input"
placeholder="dd.MM.yyyy"
showClear
[parseDate]="parseDate"
/>
</hlm-date-picker>
<hlm-field-description>Type a date (dd.MM.yyyy) or pick one from the calendar.</hlm-field-description>
</hlm-field>
<hlm-field orientation="horizontal">
<button type="submit" hlmBtn [disabled]="form().submitting()">Submit</button>
</hlm-field>
</hlm-field-group>
</form>
`,
})
export class DatePickerFormInputExample {
protected readonly _model = signal<{ birthday: Date | null }>({ birthday: null });
public readonly form = form(
this._model,
(schemaPath) => {
required(schemaPath.birthday, { message: 'Please select a date' });
},
{
submission: {
action: async () => {
const model = this._model();
console.log(model);
},
},
},
);
/** The maximum date */
public maxDate = new Date();
/** Open the calendar at "today minus 18 years" - a reasonable anchor for a date-of-birth picker. */
public defaultFocusedDate = DateTime.now().minus({ years: 18 }).toJSDate();
/** Format dates as `dd.MM.yyyy` (e.g. `01.07.2026`). */
public formatDate = (date: Date): string => DateTime.fromJSDate(date).toFormat('dd.MM.yyyy');
/** Parse `dd.MM.yyyy` strings back into `Date` instances. */
public parseDate = (value: string): Date | null => {
const dt = DateTime.fromFormat(value, 'dd.MM.yyyy');
return dt.isValid ? dt.toJSDate() : null;
};
}Form Multiple Selection
Sync the dates to a form by adding formControlName to hlm-date-picker-multi .
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { form, FormField, FormRoot, minLength, required } from '@angular/forms/signals';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmDatePickerImports } from '@spartan-ng/helm/date-picker';
import { HlmFieldImports } from '@spartan-ng/helm/field';
@Component({
selector: 'spartan-date-picker-form-multiple',
imports: [FormRoot, FormField, HlmDatePickerImports, HlmButtonImports, HlmFieldImports],
changeDetection: ChangeDetectionStrategy.OnPush,
host: { class: 'w-full max-w-xs' },
template: `
<form [formRoot]="form">
<hlm-field-group>
<hlm-field>
<label hlmFieldLabel for="date-available-dates">Available dates</label>
<hlm-date-picker-multi
[minDate]="minDate"
[maxDate]="maxDate"
[formField]="form.availableDates"
[autoCloseOnMaxSelection]="true"
[minSelection]="2"
[maxSelection]="4"
>
<hlm-date-picker-trigger buttonId="date-available-dates">Pick dates</hlm-date-picker-trigger>
</hlm-date-picker-multi>
</hlm-field>
<hlm-field orientation="horizontal">
<button type="submit" hlmBtn [disabled]="form().submitting()">Submit</button>
</hlm-field>
</hlm-field-group>
</form>
`,
})
export class DatePickerFormMultipleExample {
protected readonly _model = signal<{ availableDates: Date[] }>({ availableDates: [] });
public readonly form = form(
this._model,
(schemaPath) => {
required(schemaPath.availableDates, { message: 'Please select a date' });
minLength(schemaPath.availableDates, 1, { message: 'Select at least one date' });
},
{
submission: {
action: async () => {
const model = this._model();
console.log(model);
},
},
},
);
/** The minimum date */
public minDate = new Date(2023, 0, 1);
/** The maximum date */
public maxDate = new Date(2030, 11, 31);
}Form Range Picker
Sync the dates to a form by adding formControlName to hlm-date-range-picker .
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { form, FormField, FormRoot, required } from '@angular/forms/signals';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmDatePickerImports } from '@spartan-ng/helm/date-picker';
import { HlmFieldImports } from '@spartan-ng/helm/field';
@Component({
selector: 'spartan-date-picker-form-range',
imports: [FormRoot, FormField, HlmButtonImports, HlmDatePickerImports, HlmFieldImports],
changeDetection: ChangeDetectionStrategy.OnPush,
host: { class: 'w-full max-w-xs' },
template: `
<form [formRoot]="form">
<hlm-field-group>
<hlm-field>
<label hlmFieldLabel for="date-range-form">Enter a date range</label>
<hlm-date-range-picker
[minDate]="minDate"
[maxDate]="maxDate"
[formField]="form.range"
[autoCloseOnEndSelection]="true"
>
<hlm-date-picker-trigger buttonId="date-range-form">Pick date range</hlm-date-picker-trigger>
</hlm-date-range-picker>
</hlm-field>
<hlm-field orientation="horizontal">
<button type="submit" hlmBtn [disabled]="form().submitting()">Submit</button>
</hlm-field>
</hlm-field-group>
</form>
`,
})
export class DatePickerFormRangeExample {
protected readonly _model = signal<{ range: [Date, Date] | null }>({ range: null });
public readonly form = form(
this._model,
(schemaPath) => {
required(schemaPath.range, { message: 'Please select a date' });
},
{
submission: {
action: async () => {
const model = this._model();
console.log(model);
},
},
},
);
/** The minimum date */
public minDate = new Date(2023, 0, 1);
/** The maximum date */
public maxDate = new Date(2030, 11, 31);
}RTL
To enable RTL support in spartan-ng, see the RTL configuration guide.
import { Component, computed, effect, inject, untracked } from '@angular/core';
import { TranslateService, Translations } from '@spartan-ng/app/app/shared/translate.service';
import {
type BrnCalendarI18n,
injectBrnCalendarI18n,
type MonthLabels,
provideBrnCalendarI18n,
} from '@spartan-ng/brain/calendar';
import { HlmDatePickerImports } from '@spartan-ng/helm/date-picker';
import { HlmFieldImports } from '@spartan-ng/helm/field';
import { DateTime } from 'luxon';
export const CALENDAR_I18N: Record<'en' | 'ar' | 'he', BrnCalendarI18n> = {
en: {
formatWeekdayName: (i) => ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'][i],
months: () => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] as MonthLabels,
years: (startYear = 1925, endYear = new Date().getFullYear() + 1) =>
Array.from({ length: endYear - startYear + 1 }, (_, i) => startYear + i),
formatHeader: (month, year) => new Date(year, month).toLocaleDateString('en', { month: 'long', year: 'numeric' }),
formatMonth: (m) => new Date(2000, m).toLocaleDateString('en', { month: 'short' }),
formatYear: (y) => `${y}`,
labelPrevious: () => 'Previous month',
labelNext: () => 'Next month',
labelWeekday: (i) => ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][i],
firstDayOfWeek: () => 0,
},
ar: {
formatWeekdayName: (i) => ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'][i],
months: () =>
[
'يناير',
'فبراير',
'مارس',
'أبريل',
'مايو',
'يونيو',
'يوليو',
'أغسطس',
'سبتمبر',
'أكتوبر',
'نوفمبر',
'ديسمبر',
] as MonthLabels,
years: (startYear = 1925, endYear = new Date().getFullYear() + 1) =>
Array.from({ length: endYear - startYear + 1 }, (_, i) => startYear + i),
formatHeader: (month, year) => new Date(year, month).toLocaleDateString('ar', { month: 'long', year: 'numeric' }),
formatMonth: (m) => new Date(2000, m).toLocaleDateString('ar', { month: 'short' }),
formatYear: (y) => `${y}`,
labelPrevious: () => 'الشهر السابق',
labelNext: () => 'الشهر التالي',
labelWeekday: (i) => ['الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'][i],
firstDayOfWeek: () => 0,
},
he: {
formatWeekdayName: (i) => ['א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ש'][i],
months: () =>
[
'ינואר',
'פברואר',
'מרץ',
'אפריל',
'מאי',
'יוני',
'יולי',
'אוגוסט',
'ספטמבר',
'אוקטובר',
'נובמבר',
'דצמבר',
] as MonthLabels,
years: (startYear = 1925, endYear = new Date().getFullYear() + 1) =>
Array.from({ length: endYear - startYear + 1 }, (_, i) => startYear + i),
formatHeader: (month, year) => new Date(year, month).toLocaleDateString('he', { month: 'long', year: 'numeric' }),
formatMonth: (m) => new Date(2000, m).toLocaleDateString('he', { month: 'short' }),
formatYear: (y) => `${y}`,
labelPrevious: () => 'החודש הקודם',
labelNext: () => 'החודש הבא',
labelWeekday: (i) => ['ראשון', 'שני', 'שלישי', 'רביעי', 'חמישי', 'שישי', 'שבת'][i],
firstDayOfWeek: () => 0,
},
} as const;
@Component({
selector: 'spartan-date-picker-rtl',
imports: [HlmDatePickerImports, HlmFieldImports],
providers: [provideBrnCalendarI18n()],
template: `
<hlm-field [dir]="_dir()">
<hlm-date-picker [minDate]="minDate" [maxDate]="maxDate" [formatDate]="_formatDate()">
<hlm-date-picker-trigger buttonId="date">{{ _t()['placeholder'] }}</hlm-date-picker-trigger>
</hlm-date-picker>
</hlm-field>
`,
})
export class DatePickerRtl {
/** The minimum date */
public minDate = new Date(2023, 0, 1);
/** The maximum date */
public maxDate = new Date(2030, 11, 31);
private readonly _language = inject(TranslateService).language;
private readonly _calendarI18n = injectBrnCalendarI18n();
constructor() {
effect(() => {
const language = this._language();
untracked(() => this._calendarI18n.use(CALENDAR_I18N[language]));
});
}
protected readonly _formatDate = computed(() => {
const locale = this._language();
return (date: Date) => DateTime.fromJSDate(date).setLocale(locale).toLocaleString(DateTime.DATE_FULL);
});
private readonly _translations: Translations = {
en: {
dir: 'ltr',
values: {
placeholder: 'Pick a date',
},
},
ar: {
dir: 'rtl',
values: {
placeholder: 'اختر تاريخًا',
},
},
he: {
dir: 'rtl',
values: {
placeholder: 'בחר תאריך',
},
},
};
private readonly _translation = computed(() => this._translations[this._language()]);
protected readonly _t = computed(() => this._translation().values);
protected readonly _dir = computed(() => this._translation().dir);
}Helm API
HlmDateMultiInput
Selector: hlm-date-multi-input
ExportAs: hlmDateMultiInput
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| parseDate | (value: string) => T[] | null | this._config.parseDate | Parses input text into dates. Return `null` for invalid input - the picker's dates are cleared while the text is preserved so the user can fix it. Defaults to `parseDate` from `HlmDatePickerMultiConfig`. |
| formatInputDates | (dates: T[]) => string | this._config.formatInputDates | Formats the current dates into the input/edit format shown while the input is focused. On blur the picker's display format is restored. Defaults to `formatInputDates` from `HlmDatePickerMultiConfig`. |
| inputId | string | `hlm-date-picker-input-${BrnDateInput._nextId++}` | - |
| inputValue | string | '' | Initial text shown in the input. Mirrored by the picker once a date is committed. |
| showClear | boolean | true | Show a clear button that resets the input and picker value. Hidden when empty. |
| openOnClick | boolean | false | Open the popover on input click. |
| forceInvalid | boolean | false | Forces the invalid state visually, regardless of form control state. |
| aria-label | string | null | null | Accessible name of the text input. Forwarded to the inner `<input>`, not the host. |
| aria-labelledby | string | null | null | Id(s) of the element(s) labelling the text input. Forwarded to the inner `<input>`, not the host. |
| aria-describedby | string | null | null | Id(s) of the element(s) describing the text input. Forwarded to the inner `<input>`, not the host. |
| aria-invalid | boolean | undefined | undefined | Manual override for aria-invalid, e.g. for server-side validation errors. When not set, it follows the error state matcher (and `forceInvalid`). |
| clearAriaLabel | string | 'Clear date' | Accessible label for the clear button. |
| calendarAriaLabel | string | 'Open calendar' | Accessible label for the calendar trigger button. |
| placeholder | string | '' | - |
HlmDatePickerAnchor
Selector: [hlmDatePickerAnchor]
ExportAs: hlmDatePickerAnchor
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| hlmDatePickerAnchorFor | BrnPopover | undefined | undefined | - |
HlmDatePickerInput
Selector: hlm-date-picker-input
ExportAs: hlmDatePickerInput
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| parseDate | (value: string) => T | null | this._config.parseDate | Parses input text into a date value. Return `null` for invalid input - the picker's date is cleared while the text is preserved so the user can fix it. Defaults to `parseDate` from `HlmDatePickerConfig`. |
| formatInputDate | (date: T) => string | this._config.formatInputDate | Formats the current date into the input/edit format shown while the input is focused. On blur the picker's display format is restored. Defaults to `formatInputDate` from `HlmDatePickerConfig`. |
| inputId | string | `hlm-date-picker-input-${BrnDateInput._nextId++}` | - |
| inputValue | string | '' | Initial text shown in the input. Mirrored by the picker once a date is committed. |
| showClear | boolean | true | Show a clear button that resets the input and picker value. Hidden when empty. |
| openOnClick | boolean | false | Open the popover on input click. |
| forceInvalid | boolean | false | Forces the invalid state visually, regardless of form control state. |
| aria-label | string | null | null | Accessible name of the text input. Forwarded to the inner `<input>`, not the host. |
| aria-labelledby | string | null | null | Id(s) of the element(s) labelling the text input. Forwarded to the inner `<input>`, not the host. |
| aria-describedby | string | null | null | Id(s) of the element(s) describing the text input. Forwarded to the inner `<input>`, not the host. |
| aria-invalid | boolean | undefined | undefined | Manual override for aria-invalid, e.g. for server-side validation errors. When not set, it follows the error state matcher (and `forceInvalid`). |
| clearAriaLabel | string | 'Clear date' | Accessible label for the clear button. |
| calendarAriaLabel | string | 'Open calendar' | Accessible label for the calendar trigger button. |
| placeholder | string | '' | - |
HlmDatePickerMulti
Selector: hlm-date-picker-multi
ExportAs: hlmDatePickerMulti
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| align | BrnPopoverAlign | 'center' | - |
| captionLayout | 'dropdown' | 'label' | 'dropdown-months' | 'dropdown-years' | 'label' | Show dropdowns to navigate between months or years. |
| minDate | T | - | The minimum date that can be selected. |
| maxDate | T | - | The maximum date that can be selected. |
| minSelection | number | undefined | The minimum selectable dates. |
| maxSelection | number | undefined | The maximum selectable dates. |
| disabled | boolean | false | Determine if the date picker is disabled. |
| date | T[] | - | The selected value. |
| autoCloseOnMaxSelection | boolean | this._config.autoCloseOnMaxSelection | If true, the date picker will close when the max selection of dates is reached. |
| formatDates | (date: T[]) => string | this._config.formatDates | Defines how the date should be displayed in the UI. |
| transformDates | (date: T[]) => T[] | this._config.transformDates | Defines how the date should be transformed before saving to model/form. |
Outputs
| Prop | Type | Default | Description |
|---|---|---|---|
| dateChange | T[] | - | - |
HlmDatePickerTrigger
Selector: hlm-date-picker-trigger
ExportAs: hlmDatePickerTrigger
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| class | ClassValue | '' | - |
| buttonId | string | `hlm-date-picker-${++HlmDatePickerTrigger._nextId}` | The id of the button that opens the date picker. |
| forceInvalid | boolean | false | Forces the invalid state visually, regardless of form control state. |
| variant | ButtonVariants['variant'] | 'outline' | - |
| showTrigger | boolean | true | - |
HlmDatePicker
Selector: hlm-date-picker
ExportAs: hlmDatePicker
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| align | BrnPopoverAlign | 'center' | - |
| captionLayout | 'dropdown' | 'label' | 'dropdown-months' | 'dropdown-years' | 'label' | Show dropdowns to navigate between months or years. |
| minDate | T | - | The minimum date that can be selected. |
| maxDate | T | - | The maximum date that can be selected. |
| disabled | boolean | false | Determine if the date picker is disabled. |
| date | T | - | The selected value. |
| defaultFocusedDate | T | - | The date the calendar focuses on first open when no date is selected. |
| autoCloseOnSelect | boolean | this._config.autoCloseOnSelect | If true, the date picker will close when a date is selected. |
| formatDate | (date: T) => string | this._config.formatDate | Defines how the date should be displayed in the UI. |
| transformDate | (date: T) => T | this._config.transformDate | Defines how the date should be transformed before saving to model/form. |
Outputs
| Prop | Type | Default | Description |
|---|---|---|---|
| dateChange | T | null | - | - |
HlmDateRangeInput
Selector: hlm-date-range-input
ExportAs: hlmDateRangeInput
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| parseDate | (value: string) => [T, T] | null | this._config.parseDate | Parses input text into a date range. Return `null` for invalid input - the picker's range is cleared while the text is preserved so the user can fix it. Defaults to `parseDate` from `HlmDateRangePickerConfig`. |
| formatInputDates | (dates: [T | null, T | null]) => string | this._config.formatInputDates | Formats the current range into the input/edit format shown while the input is focused. On blur the picker's display format is restored. Defaults to `formatInputDates` from `HlmDateRangePickerConfig`. |
| inputId | string | `hlm-date-picker-input-${BrnDateInput._nextId++}` | - |
| inputValue | string | '' | Initial text shown in the input. Mirrored by the picker once a date is committed. |
| showClear | boolean | true | Show a clear button that resets the input and picker value. Hidden when empty. |
| openOnClick | boolean | false | Open the popover on input click. |
| forceInvalid | boolean | false | Forces the invalid state visually, regardless of form control state. |
| aria-label | string | null | null | Accessible name of the text input. Forwarded to the inner `<input>`, not the host. |
| aria-labelledby | string | null | null | Id(s) of the element(s) labelling the text input. Forwarded to the inner `<input>`, not the host. |
| aria-describedby | string | null | null | Id(s) of the element(s) describing the text input. Forwarded to the inner `<input>`, not the host. |
| aria-invalid | boolean | undefined | undefined | Manual override for aria-invalid, e.g. for server-side validation errors. When not set, it follows the error state matcher (and `forceInvalid`). |
| clearAriaLabel | string | 'Clear date' | Accessible label for the clear button. |
| calendarAriaLabel | string | 'Open calendar' | Accessible label for the calendar trigger button. |
| placeholder | string | '' | - |
HlmDateRangePicker
Selector: hlm-date-range-picker
ExportAs: hlmDateRangePicker
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| align | BrnPopoverAlign | 'center' | - |
| captionLayout | 'dropdown' | 'label' | 'dropdown-months' | 'dropdown-years' | 'label' | Show dropdowns to navigate between months or years. |
| numberOfMonths | number | this._config.numberOfMonths | The number of months to display in the calendar. |
| minDate | T | - | The minimum date that can be selected. |
| maxDate | T | - | The maximum date that can be selected. |
| disabled | boolean | false | Determine if the date picker is disabled. |
| date | [T, T] | - | The selected value. |
| autoCloseOnEndSelection | boolean | this._config.autoCloseOnEndSelection | If true, the date picker will close when the end date is selected |
| formatDates | (dates: [T | null, T | null]) => string | this._config.formatDates | Defines how the date should be displayed in the UI. |
| transformDates | (date: [T, T]) => [T, T] | this._config.transformDates | Defines how the date should be transformed before saving to model/form. |
Outputs
| Prop | Type | Default | Description |
|---|---|---|---|
| dateChange | [T, T] | null | - | - |
HlmMonthYearInput
Selector: hlm-month-year-input
ExportAs: hlmMonthYearInput
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| parseDate | (value: string) => T | null | this._config.parseDate | Parses input text into a date value. Return `null` for invalid input - the picker's date is cleared while the text is preserved so the user can fix it. Defaults to `parseDate` from `HlmMonthYearPickerConfig`. |
| formatInputDate | (date: T) => string | this._config.formatInputDate | Formats the current date into the input/edit format shown while the input is focused. On blur the picker's display format is restored. Defaults to `formatInputDate` from `HlmMonthYearPickerConfig`. |
| inputId | string | `hlm-date-picker-input-${BrnDateInput._nextId++}` | - |
| inputValue | string | '' | Initial text shown in the input. Mirrored by the picker once a date is committed. |
| showClear | boolean | true | Show a clear button that resets the input and picker value. Hidden when empty. |
| openOnClick | boolean | false | Open the popover on input click. |
| forceInvalid | boolean | false | Forces the invalid state visually, regardless of form control state. |
| aria-label | string | null | null | Accessible name of the text input. Forwarded to the inner `<input>`, not the host. |
| aria-labelledby | string | null | null | Id(s) of the element(s) labelling the text input. Forwarded to the inner `<input>`, not the host. |
| aria-describedby | string | null | null | Id(s) of the element(s) describing the text input. Forwarded to the inner `<input>`, not the host. |
| aria-invalid | boolean | undefined | undefined | Manual override for aria-invalid, e.g. for server-side validation errors. When not set, it follows the error state matcher (and `forceInvalid`). |
| clearAriaLabel | string | 'Clear date' | Accessible label for the clear button. |
| calendarAriaLabel | string | 'Open calendar' | Accessible label for the calendar trigger button. |
| placeholder | string | '' | - |
HlmMonthYearPicker
Selector: hlm-month-year-picker
ExportAs: hlmMonthYearPicker
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| align | BrnPopoverAlign | 'center' | - |
| minDate | T | - | The minimum date that can be selected. |
| maxDate | T | - | The maximum date that can be selected. |
| disabled | boolean | false | Determine if the date picker is disabled. |
| date | T | - | The selected value. |
| defaultFocusedDate | T | - | The date the calendar focuses on first open when no date is selected. |
| autoCloseOnSelect | boolean | this._config.autoCloseOnSelect | If true, the date picker will close when a date is selected. |
| formatDate | (date: T) => string | this._config.formatDate | Defines how the date should be displayed in the UI. |
| transformDate | (date: T) => T | this._config.transformDate | Defines how the date should be transformed before saving to model/form. |
Outputs
| Prop | Type | Default | Description |
|---|---|---|---|
| dateChange | T | null | - | - |
On This Page