GUILD OF GLEKS UIv21.4.4

gog-datepicker

Datepicker

A date field with a calendar panel: a single date, a range, and an optional clock. Native Date, no date library and no adapter abstraction — the package keeps its zero runtime dependencies.

Overview

Import the component and drop it into a template.

typescript
import { DatepickerComponent } from '@guildofgleks/ui';

@Component({
  // ...
  imports: [DatepickerComponent],
})

Basic usage:

<gog-datepicker label="Date of birth" [max]="today" [(value)]="birthday" />

One pattern, both directions

format is a token pattern — yyyy, MM, dd, HH, hh, mm, ss, a — and it is used for both rendering and parsing. That is what makes allowTextInput safe: whatever the field displays can be typed back in. 31.02.2026 is rejected rather than silently becoming 3 March, which is what a naive new Date(text) would do.

Type into this one — it renders and parses yyyy-MM-dd.

<!-- The same pattern renders and parses, so what is written can be read back. -->
<gog-datepicker label="ISO" format="yyyy-MM-dd" [(value)]="isoDate" />

Examples

Range

selectionMode="range" makes the value a { start, end } pair. Pair it with [numberOfMonths]="2" — picking a range one month at a time is painful.

<gog-datepicker
  label="Stay"
  selectionMode="range"
  [numberOfMonths]="2"
  [(value)]="stay"
/>

Date and time

showTime adds the clock. Leave format unset and it widens to include HH:mm automatically; if you set format explicitly, widen it yourself to match, or the field will render a time it cannot read back.

<gog-datepicker
  label="Meeting"
  format="dd.MM.yyyy HH:mm"
  [showTime]="true"
  hourFormat="24"
  [minuteStep]="15"
  [(value)]="meeting"
/>

Inline

inline drops the field and shows the calendar permanently. It is literally gog-calendar rendered without the field around it.

August 2026
SunMonTueWedThuFriSat
<gog-datepicker [inline]="true" [(value)]="inlineDate" />

Forms, validation, disabled dates and clearing

A ControlValueAccessor, so formControl / formControlName work directly. disabledDates is a predicate — an array cannot express "weekends". The clear button appears only once a date is set.

<gog-datepicker
  label="Deadline"
  errorDisplay="auto"
  errorMessage="A deadline is required"
  [clearable]="true"
  [disabledDates]="weekends"
  [formControl]="deadline"
/>

The panel's footer carries two separate actions, never one: showTodayButton (on by default) selects today, and showThisMonthButton (off by default) only moves the view back to the current month. A single button doing both is ambiguous — after paging away, the same label reads as "take me back" to one person and "set it to today" to another.

"Today" is disabled when min/max or disabledDates rule today out, rather than silently doing nothing when pressed.

App-wide defaults

A locale and a date format repeated on every date input is exactly the boilerplate GOG_CONFIG exists to remove. An instance's own input always wins.

typescript
import { provideGogConfig } from '@guildofgleks/ui';

bootstrapApplication(App, {
  providers: [
    provideGogConfig({
      datepicker: {
        locale: 'de-DE',
        firstDayOfWeek: 1,
        format: 'dd.MM.yyyy',
      },
    }),
  ],
});

API Reference

Inputs

NameTypeDefaultDescription
valueDate | GogDateRange | nullnullThe selection: a Date in single mode, a { start, end } pair in range mode. Two-way bindable with [(value)].
selectionMode'single' | 'range''single'Whether the field picks one day or a start/end pair.
formatstring | nullGOG_CONFIG.datepicker.format ?? 'dd.MM.yyyy' (or '... HH:mm' when showTime is true)A token pattern (yyyy, MM, dd, HH, hh, mm, ss, a) used for BOTH rendering and parsing, so what is written can always be read back. Left unset, it is derived from showTime automatically; an explicit value overrides that derivation, so widen it yourself if you set one and also turn showTime on.
localestringGOG_CONFIG.datepicker.locale ?? 'en-US'BCP-47 tag driving month and weekday names, through Intl.
firstDayOfWeeknumberGOG_CONFIG.datepicker.firstDayOfWeek ?? from the locale0 = Sunday … 6 = Saturday.
min / maxDate | nullnullSelectable bounds.
disabledDates((date: Date) => boolean) | nullnullExtra exclusions as a predicate — an array cannot express "weekends".
defaultMonthDate | nullnullWhich month the panel opens on when there is no selection yet.
numberOfMonthsnumber1Months shown side by side. Two is what makes a range picker usable.
showTimebooleanfalseAdds a clock under the grid.
hourFormat / minuteStep / showSeconds'12' | '24' / number / boolean'24' / 1 / falseHow that clock is configured.
showTodayButton / showThisMonthButtonbooleantrue / falseTwo separate footer actions: "Today" SELECTS today; "This month" only moves the view back.
todayLabel / thisMonthLabel / openCalendarLabel / clearAriaLabelstring'Today' / 'This month' / 'Open calendar' / 'Clear date'Wording for the footer actions and the two icon buttons.
allowTextInputbooleantrueWhether the date can be typed as well as picked. Parsing uses the same pattern as rendering, so 31.02.2026 is rejected rather than silently becoming 3 March.
inlinebooleanfalseRenders the calendar always-visible, with no field. Literally gog-calendar on its own.
clearablebooleanGOG_CONFIG.control.clearable ?? falseA clear button, shown only once a date is set.
label / ariaLabel / placeholder / inputIdstring''Field label, accessible name, placeholder, and an id for an external <label>.
floatLabel / floatLabelShowPlaceholder'none' | 'in' | 'on' | 'over' / booleanGOG_CONFIG.floatLabel.* ?? 'none' / falseFloat-label variant and whether the placeholder reappears once it has floated.
errorMessage / errorDisplaystring / 'manual' | 'auto''' / GOG_CONFIG.control.errorDisplay ?? 'manual'Validation message, shown manually or derived from the bound form control.
size / disabled / fullWidthGogSize / boolean / booleanGOG_CONFIG.control.size ?? 'md' / false / trueDensity, disabled state, and how the field sizes itself.
appendToBody / dropdownDirection / dropdownZIndexboolean / GogDropdownDirection / number | nullGOG_CONFIG.dropdown.* ?? component defaultsPanel placement. appendToBody renders it into <body> so an overflow-clipped ancestor cannot cut it off.

Outputs

NamePayloadDescription
valueChangeDate | GogDateRange | nullEmitted when the selection changes. Comes from the value model input.

Styling Tokens

Every CSS custom property the field and its panel paint with. The grid inside the panel is themed by gog-calendar's own --gog-calendar-* tokens. See the Theming guide for the full token-layering model, or the Theme Generator to tweak these live.

TokenDescription
--gog-datepicker-label-colorField label color.
--gog-datepicker-field-bg / -border-color / -text-colorField surface, border and text.
--gog-datepicker-radius / -min-widthField corner radius and minimum width.
--gog-datepicker-focus-ring-color / -focus-ring-width / -hover-border-colorFocus and hover states.
--gog-datepicker-icon-color / -icon-hover-color / -toggle-icon-sizeThe calendar toggle icon.
--gog-datepicker-panel-bg / -panel-border-color / -panel-shadow / -panel-radiusThe panel wrapping the calendar. The grid itself is themed by --gog-calendar-*.
--gog-datepicker-panel-widthWidth of the dropdown panel, max-content by default. Inline mode has no panel — it is gog-calendar on its own, so it sizes from --gog-calendar-max-width.
--gog-datepicker-clear-color / -clear-icon-ratio / -actions-insetClear button color, glyph size and inset.
--gog-datepicker-error-color / -error-border-color / -error-font-sizeValidation error message and border.
--gog-datepicker-float-label-reserve / -in-top / -over-gap / -over-reserveFloat-label geometry, derived from the shared --gog-field-float-label-* scale.