Skip to content

Date & time

Date pickers and time pickers allow users to select and navigate through past, present, and future dates and times.

Usage

These components are used in scenarios where users need to input specific dates, times, or date ranges.

Date pickers typically include an expandable calendar menu and a text input field, while time pickers focus solely on time selection, usually a text input field or dropdown menu for selecting specific times.

Date time

When to use

  • To collect absolute date and time inputs.
  • For scheduling tasks.
  • In forms.
  • To select date ranges for generating reports or viewing historical data.
  • For relative date selection, use date range filter.

Best practices

  • Ensure the format of dates and times adheres to the user's locale settings. See localization for more details.
  • Ensure placeholders are also localized to match the user's regional settings (e.g., "MM/DD/YYYY").
  • When required, validation can be set for all time inputs.
  • Provide clear and concise labels for input fields.

Design

Basic anatomy

Date pickers and date-time pickers consist of an optional input field and a calendar view. The input field allows users to manually type dates and times. When needed, the calendar view opens for visual selection, making this structure common across all variants.

Date picker anatomy

  1. Label (optional), 2. Input, 3. Calendar button, 4. Month & Year control, 5. Previous and Next month control, 6. Default day, 7. Selected day, 8. Current day, 9. Off month day, 10. Today control

Single date and date-time picker

The single date picker allows users to select a specific date, either by typing in the input field or using the calendar view. When the time option is enabled, users can also select a specific time.

Single date picker

Date and date-time range picker

The date range picker enables users to choose a start and end date. When the time option is enabled, a two-month view layout is used.

Date range picker

Time picker

The time picker is a component with separate input fields for individually setting units of time measurement (e.g., hh, mm, …). Minutes, seconds, and milliseconds are optional and can be configured to show or hide as needed.

Date range picker

Code

The datepicker and timepicker components are highly configurable. The datepicker optionally includes the timepicker.

The SiDatepickerComponent, SiTimepickerComponent, as well as the SiDatepickerDirective, to attach the datepicker component to a HTML input element, are provided by the SiDatepickerModule Angular module.

Usage

Datepicker can be imported using the module

import { SiDatepickerModule } from '@siemens/element-ng/datepicker';

@NgModule({
  imports: [SiDatepickerModule, ...]
})

or as a standalone component:

import {
  SiDateInputDirective,
  SiDatepickerComponent,
  SiDatepickerDirective,
  SiDateRangeComponent
} from '@siemens/element-ng/datepicker';

@Component({
  imports: [
    SiDateInputDirective,
    SiDatepickerComponent,
    SiDatepickerDirective,
    SiDateRangeComponent,
    ...
  ]
})

Datepicker without time

The datepicker component can be added to any view. Bidirectional binding of the date object is provided by the date property. The configuration is handled by the config object as documented in the API.

Datepicker with time control

  • Setting showTime in the config will display the timepicker within the date picker.
  • A switch enables the user to include (Consider time) the time or not (Ignore time).
  • Initial switch enablement is controlled by the disabledTime flag and changes are emitted by the disabledTimeChange output property.
  • Use the mandatoryTime flag to hide the switch.

Datepicker with date range

The si-datepicker allows to pick date ranges. Use the two-way binded property dateRange and set enableDateRange: true in configuration.

Input element with datepicker

The SiDatepickerDirective attaches the datepicker to an HTML input element. Without any additional configuration, the Angular locale date formatter is used to write the selected date into the input field. Changes of the input field are also parsed and used to set the date in the datepicker. Optionally, you can provide a custom date and time format using the config object.

The directive implements the Angular ControlValueAccessor and can be used in Angular Forms.

Input element with date range picker

The SiDateRangeComponent component is a custom component which can be used to use datepicker as range selector.

The component implements the Angular ControlValueAccessor and can be used in Angular Forms.

Timepicker

The timepicker component is a custom component with individual input fields for setting the parts of the time individually, like hours, and minutes. It implements the ControlValueAccessor and can be used in Angular Forms.

SiDatepickerComponent API Documentation

selector
si-datepicker

Input Properties

Name Type Default Description
activeHover
Cell The cell which which has the mouse hover.
calendarWeekLabel
TranslatableString $localize`:@@SI_DATEPICKER.CALENDAR_WEEK_LABEL:Calendar week` Aria label for week number column
config
DatepickerConfig {} Object to configure the datepicker.
date
Date The selected date of the datepicker. Use for initialization and for bidirectional binding.
dateRange
DateRange The selected date range of the datepicker. Use for initialization and for bidirectional binding.
dateRangeRole
RangeType Role of this calendar when a date range is displayed across two calendars.
disabledTime
boolean false Disabled the optional visible time picker.
focusedDate
Date The date which is currently focused Compare to the selected date or range the calendar requires to have one element to focus.
hideCalendar
boolean false Whether the calendar is hidden while retaining the optional timepicker.
hideTimeToggle
boolean false Option to hide the time switch.
initialFocus
boolean false Set initial focus to calendar body.
maxMonth
Date Optional input to control the maximum month the datepicker can show and the user can navigate. The maxMonth can be smaller than the maxDate This option enables the usage of multiple datepickers next to each other while the more left calendar always shows a earlier month the the more right one.
minMonth
Date Optional input to control the minimum month the datepicker can show and the user can navigate. The minMonth can be larger than the minDate This option enables the usage of multiple datepickers next to each other while the more left calendar always shows a earlier month the the more right one.
nextLabel
TranslatableString $localize`:@@SI_DATEPICKER.NEXT:Next` Aria label for the next button. Needed for a11y.
previousLabel
TranslatableString $localize`:@@SI_DATEPICKER.PREVIOUS:Previous` Aria label for the previous button. Needed for a11y.
rangeType
RangeType 'START' Use this to force date range operation to select either start date or end date.
time12h
boolean undefined Enable/disable 12H mode in timepicker. Defaults to locale
timepickerLabel
string Optional timepicker label.

Output Properties

Name Type Description
activeHoverChange
Cell The cell which which has the mouse hover.
configChange
DatepickerConfig Object to configure the datepicker.
dateChange
Date The selected date of the datepicker. Use for initialization and for bidirectional binding.
dateRangeChange
DateRange The selected date range of the datepicker. Use for initialization and for bidirectional binding.
disabledTimeChange
boolean Disabled the optional visible time picker.
focusedDateChange
Date The date which is currently focused Compare to the selected date or range the calendar requires to have one element to focus.
rangeTypeChange
RangeType Use this to force date range operation to select either start date or end date.

Attributes and Methods

Name Type Default Description
focusActiveCell()
() => void Focus the active cell in view. The function is required to transfer the focus from input to the active date cell.

SiDateRangeComponent API Documentation

selector
si-date-range

Common interface for form item controls. Controls that should be connected to SiFormItemComponent must implement this interface and must be provided using the SI_FORM_ITEM_CONTROL token.

Input Properties

Name Type Default Description
ariaLabelCalendarButton
TranslatableString $localize`:@@SI_DATEPICKER.CALENDAR_TOGGLE_BUTTON:Open calendar` Aria label of the date-range calendar toggle button.
autoClose
boolean false Automatically close overlay on date selection.
disabled
boolean false Whether the date range input is disabled.
endDatePlaceholder
TranslatableString $localize`:@@SI_DATEPICKER.END_DATE_PLACEHOLDER:End date` Placeholder of the end date input.
endTimeLabel
TranslatableString $localize`:@@SI_DATEPICKER.END_TIME_LABEL:To` Form label of the start timepicker.
errormessageId
string ${this.id()}-errormessage This ID will be bound to the aria-describedby attribute of the date-range. Use this to reference the element containing the error message(s) for the date-range. It will be picked by the SiFormItemComponent if the date-range is used inside a form item.
id
string __si-date-range-${SiDateRangeComponent.idCounter++}
readonly
boolean false Whether the date range input is readonly.
scrollStrategy
ScrollStrategy defaultConnectedOverlayScrollStrategy() Optional CDK scroll strategy used for the datepicker overlay.
siDatepickerConfig
DatepickerInputConfig { enableDateRange: true } Date range component configuration.
startDatePlaceholder
TranslatableString $localize`:@@SI_DATEPICKER.START_DATE_PLACEHOLDER:Start date` Placeholder of the start date input.
startTimeLabel
TranslatableString $localize`:@@SI_DATEPICKER.START_TIME_LABEL:From` Form label of the start timepicker.
value
DateRange Set the date-range object displayed in the control. The input can be used if the control is used outside Angular forms.

Output Properties

Name Type Description
disabledTimeChange
boolean Emits an event to notify about disabling the time from the range picker. When time is disable, we construct a pure date objects in UTC 00:00:00 time.
siDatepickerClose
CloseCause Output event on closing datepicker e.g. by clicking backdrop or escape key.
siDatepickerConfigChange
DatepickerInputConfig Date range component configuration.
siDatepickerRangeChange
(DateRange | undefined) Emits on the date range value changes.
valueChange
DateRange Set the date-range object displayed in the control. The input can be used if the control is used outside Angular forms.

Attributes and Methods

Name Type Default Description
(readonly) labelledby
string ... ID that should be assigned to the label element inside the SiFormItemComponent .

If the target control is not of type input, select or button, it cannot be referenced by a label. Instead, aria-labelledby must be used to create a reference to a label. In such a case, an implementation of SiFormItemControl must provide the id of the label in labelledby . SiFormItemComponent will apply the id to the label so that it can be used inside the control to reference it in the aria-labelledby attribute.

SiTimepickerComponent API Documentation

selector
si-timepicker

Common interface for form item controls. Controls that should be connected to SiFormItemComponent must implement this interface and must be provided using the SI_FORM_ITEM_CONTROL token.

Input Properties

Name Type Default Description
disabled
boolean false All input fields will be disabled if set to true.
errormessageId
string ${this.id()}-errormessage This ID will be bound to the aria-describedby attribute of the timepicker. Use this to reference the element containing the error message(s) for the timepicker. It will be picked by the SiFormItemComponent if the timepicker is used inside a form item.
hideLabels
boolean false Hide the labels of the input fields.
hoursAriaLabel
TranslatableString $localize`:@@SI_DATEPICKER.HOURS:Hours`
hoursLabel
TranslatableString 'hh' Visible label for the hours input.
hoursPlaceholder
string 'hh' Placeholder for the hours input.
id
string __si-timepicker-${SiTimepickerComponent.idCounter++}
max
Date A maximum time limit. The date part of the date object will be ignored.
meridians
string[] Custom labels for the AM and PM options.
meridiansAriaLabel
TranslatableString $localize`:@@SI_DATEPICKER.PERIOD:Period`
meridiansLabel
TranslatableString 'am/pm' Visible label for the AM/PM selector.
millisecondsAriaLabel
TranslatableString $localize`:@@SI_DATEPICKER.MILLISECONDS:Milliseconds`
millisecondsLabel
TranslatableString 'ms' Visible label for the milliseconds input.
millisecondsPlaceholder
string 'ms' Placeholder for the milliseconds input.
min
Date A minimum time limit. The date part of the date object will be ignored.
minutesAriaLabel
TranslatableString $localize`:@@SI_DATEPICKER.MINUTES:Minutes`
minutesLabel
TranslatableString 'mm' Visible label for the minutes input.
minutesPlaceholder
string 'mm' Placeholder for the minutes input.
readonly
boolean false Whether the time inputs are read-only.
secondsAriaLabel
TranslatableString $localize`:@@SI_DATEPICKER.SECONDS:Seconds`
secondsLabel
TranslatableString 'ss' Visible label for the seconds input.
secondsPlaceholder
string 'ss' Placeholder for the seconds input.
showMeridian
boolean Show time in 12-hour period including the select to toggle between AM/PM.
showMilliseconds
boolean false Whether the milliseconds input is displayed.
showMinutes
boolean true Whether the minutes input is displayed.
showSeconds
boolean false Whether the seconds input is displayed.

Output Properties

Name Type Description
inputCompleted
void Emits when the user presses Enter in the final time input.
isValid
boolean Emits whether the entered time components form a valid time.
meridianChange
string Emits the selected meridian when it changes.

Attributes and Methods

Name Type Default Description
(readonly) labelledby
string ... ID that should be assigned to the label element inside the SiFormItemComponent .

If the target control is not of type input, select or button, it cannot be referenced by a label. Instead, aria-labelledby must be used to create a reference to a label. In such a case, an implementation of SiFormItemControl must provide the id of the label in labelledby . SiFormItemComponent will apply the id to the label so that it can be used inside the control to reference it in the aria-labelledby attribute.

SiDatepickerDirective API Documentation

selector exported-as
[siDatepicker] siDatepicker

Base directive for date input fields.

Input Properties

Name Type Default Description
autoClose
boolean false Automatically close overlay on date selection. Do not use this behavior with config showTime = true, because it will close the overlay when the user change one of the time units.
disabled
boolean false Whether the date range input is disabled.
errormessageId
string ${this.id()}-errormessage This ID will be bound to the aria-describedby attribute of the date-input. Use this to reference the element containing the error message(s) for the date-input. It will be picked by the SiFormItemComponent if the date-input is used inside a form item.
id
string si-date-input-${SiDateInputDirective.idCounter++}
readonly
boolean false Whether the date range input is readonly.
siDatepickerConfig
(DatepickerInputConfig | undefined) {} Configuration object for the datepicker.
siDatepickerScrollStrategy
ScrollStrategy defaultConnectedOverlayScrollStrategy() Optional CDK scroll strategy used for the datepicker overlay.

Output Properties

Name Type Description
dateChange
(Date | undefined) Emits a new date value on input field value changes.
siDatepickerClose
CloseCause Output event on closing datepicker e.g. by clicking backdrop or escape key.
siDatepickerConfigChange
(DatepickerInputConfig | undefined) Configuration object for the datepicker.
siDatepickerDisabledTime
boolean Emits an event to notify about disabling the time from the datepicker. When time is disable, we construct a pure date object in UTC 00:00:00 time.
stateChange
void Emits an event on state changes e.g. readonly, disable, ... .
validationChange
void

Attributes and Methods

Name Type Default Description
ngOnChanges(...)
(changes: { autoClose: false, disabled: SimpleChange<Signal<boolean>>, disabledInput: false, errormessageId: ${this.id()}-errormessage, id: si-date-input-${SiDateInputDirective.idCounter++}, ngAfterViewInit: SimpleChange<() => void>, ngOnChanges: SimpleChange<(changes: { readonly autoClose?&#58; SimpleChange&lt;boolean&gt; \| undefined; ngAfterViewInit?&#58; SimpleChange&lt;() =&gt; void&gt; \| undefined; touch?&#58; SimpleChange&lt;() =&gt; void&gt; \| undefined; ... 19 more ...; onDisabledTime?&#58; SimpleChange&lt;...&gt; \| undefined; }) => void>, onDisabledTime: SimpleChange<(disabledTime: boolean) => void>, readonly: false, registerOnChange: SimpleChange<(fn: any) => void>, registerOnTouched: SimpleChange<(fn: () => void) => void>, registerOnValidatorChange: SimpleChange<(fn: () => void) => void>, setDisabledState: SimpleChange<(isDisabled: boolean) => void>, show: SimpleChange<(initialFocus: boolean = false) => void>, siDatepickerConfig: {}, siDatepickerDisabledTime: SimpleChange<OutputEmitterRef<boolean>>, stateChange: SimpleChange<OutputEmitterRef<void>>, touch: SimpleChange<() => void>, useExternalTrigger: SimpleChange<(element: ElementRef<HTMLElement>) => void>, validate: SimpleChange<(c: AbstractControl) => (ValidationErrors | null)>, validationChange: SimpleChange<OutputEmitterRef<void>>, validatorOnChange: SimpleChange<() => void>, writeValue: SimpleChange<(value: (string | Date | null)) => void> }) => void A callback method that is invoked immediately after the default change detector has checked data-bound properties if at least one has changed, and before the view and content children are checked.

Parameters
registerOnTouched(...)
(fn: () => void) => void @description: Registers a callback function that is called by the forms API on initialization to update the form model on blur.

When implementing registerOnTouched in your own value accessor, save the given function so your class calls it when the control should be considered blurred or "touched".

@usageNotes: ### Store the callback function

The following example stores the provided function as an internal method.

registerOnTouched(fn: any): void { this._onTouched = fn; }

On blur (or equivalent), your class should call the registered function to allow the forms API to update itself:

host: { '(blur)': '_onTouched()' }

Parameters
  • fn: () => void  The callback function to register
registerOnValidatorChange(...)
(fn: () => void) => void @description: Registers a callback function to call when the validator inputs change.

Parameters
  • fn: () => void  The callback function
validate(...)
(c: AbstractControl) => (ValidationErrors | null) @description: Method that performs synchronous validation against the provided control.
Returns A map of validation errors if validation fails, otherwise null.

Parameters
writeValue(...)
(value: (string | Date | null)) => void @description: Writes a new value to the element.

This method is called by the forms API to write to the view when programmatic changes from model to view are requested.

@usageNotes: ### Write a value to the element

The following example writes a value to the native DOM element.

writeValue(value: any): void { this._renderer.setProperty(this._elementRef.nativeElement, 'value', value); }

Parameters

Types Documentation

Represents a translatable string. This can either be a translation key, e.g. ACTIONS.EDIT that will be automatically translated when displayed on the UI or a pre-translated string, e.g. Edit . Equivalent to a normal string in usage and functionality.
Properties
Defines the time is disabled when visible. Will also be updated on user change. Default is false .
disabledTime?: boolean
Text or translation key for the disabled disable time. Default is Ignore time .
disabledTimeText?: TranslatableString
Options to turn on date range selection.
enableDateRange?: boolean
Text or translation key for the enabled disable time. Default is Consider time .
enabledTimeText?: TranslatableString
Consider time with minDate and maxDate
enableTimeValidation?: boolean
Option to use two months view for date range picking.
enableTwoMonthDateRange?: boolean
endTimeLabel?: string
hideLabels?: boolean
Configuration for hiding week numbers. Default is false .
hideWeekNumbers?: boolean
hoursAriaLabel?: string
hoursLabel?: string
hoursPlaceholder?: string
Hides disable time switch in the timepicker part and includes mandatory the time in the picker.
mandatoryTime?: boolean
Maximal (latest) selectable date.
maxDate?: Date
meridians?: string[]
meridiansAriaLabel?: string
meridiansLabel?: string
millisecondsAriaLabel?: string
millisecondsLabel?: string
millisecondsPlaceholder?: string
Minimal (earliest) selectable date.
minDate?: Date
minutesAriaLabel?: string
minutesLabel?: string
minutesPlaceholder?: string
Only month and year are selectable.
onlyMonthSelection?: boolean
secondsAriaLabel?: string
secondsLabel?: string
secondsPlaceholder?: string
Defines the timepicker milliseconds visibility . Default is false .
showMilliseconds?: boolean
Defines the timepicker minutes visibility. Default is true .
showMinutes?: boolean
Defines the timepicker seconds visibility . Default is false .
showSeconds?: boolean
Defines the timepicker visibility. Default is false .
showTime?: boolean
startTimeLabel?: string
Text or translation key for today button title. Default is Today .
todayText?: TranslatableString
Defines the starting day of the week. Default is monday .
weekStartDay?: WeekStart
("START" | "END" | undefined)
("monday" | "saturday" | "sunday" | undefined)
Properties
Similar to dateTimeFormat , but used when only a date is displayed (e.g. when showTime === false or disabledTime === true ). Only numeric date formats are supported.
dateFormat?: string
A custom date/time format according the Angular date pipe (see https://angular.dev/api/common/DatePipe ). Only numeric date formats are supported. The format is used to render the time of a date-time criterion. If not specified, mediumTime is used if the showSeconds flag is true, otherwise shortTime as default. For the date-only case, 'shortDate' is used.
dateTimeFormat?: string
Defines the time is disabled when visible. Will also be updated on user change. Default is false .
disabledTime?: boolean from disabledTime
Text or translation key for the disabled disable time. Default is Ignore time .
disabledTimeText?: TranslatableString from disabledTimeText
Options to turn on date range selection.
enableDateRange?: boolean from enableDateRange
Text or translation key for the enabled disable time. Default is Consider time .
enabledTimeText?: TranslatableString from enabledTimeText
Consider time with minDate and maxDate
enableTimeValidation?: boolean from enableTimeValidation
Option to use two months view for date range picking.
enableTwoMonthDateRange?: boolean from enableTwoMonthDateRange
endTimeLabel?: string from endTimeLabel
hideLabels?: boolean from hideLabels
Configuration for hiding week numbers. Default is false .
hideWeekNumbers?: boolean from hideWeekNumbers
hoursAriaLabel?: string from hoursAriaLabel
hoursLabel?: string from hoursLabel
hoursPlaceholder?: string from hoursPlaceholder
Hides disable time switch in the timepicker part and includes mandatory the time in the picker.
mandatoryTime?: boolean from mandatoryTime
Maximal (latest) selectable date.
maxDate?: Date from maxDate
meridians?: string[] from meridians
meridiansAriaLabel?: string from meridiansAriaLabel
meridiansLabel?: string from meridiansLabel
millisecondsAriaLabel?: string from millisecondsAriaLabel
millisecondsLabel?: string from millisecondsLabel
millisecondsPlaceholder?: string from millisecondsPlaceholder
Minimal (earliest) selectable date.
minDate?: Date from minDate
minutesAriaLabel?: string from minutesAriaLabel
minutesLabel?: string from minutesLabel
minutesPlaceholder?: string from minutesPlaceholder
Only month and year are selectable.
onlyMonthSelection?: boolean from onlyMonthSelection
secondsAriaLabel?: string from secondsAriaLabel
secondsLabel?: string from secondsLabel
secondsPlaceholder?: string from secondsPlaceholder
Defines the timepicker milliseconds visibility . Default is false .
showMilliseconds?: boolean from showMilliseconds
Defines the timepicker minutes visibility. Default is true .
showMinutes?: boolean from showMinutes
Defines the timepicker seconds visibility . Default is false .
showSeconds?: boolean from showSeconds
Defines the timepicker visibility. Default is false .
showTime?: boolean from showTime
startTimeLabel?: string from startTimeLabel
Text or translation key for today button title. Default is Today .
todayText?: TranslatableString from todayText
Defines the starting day of the week. Default is monday .
weekStartDay?: WeekStart from weekStartDay
Enum members
Backdrop: "backdrop"
Detach: "detach"
Escape: "escape"
Select: "select"
Common interface for form item controls. Controls that should be connected to SiFormItemComponent must implement this interface and must be provided using the SI_FORM_ITEM_CONTROL token.
Properties
Generated ID that the SiFormItemComponent will assign to the element containing the error messages. Implementations of SiFormItemControl must generate this ID and assign it to the aria-describedby attribute of their focusable elements.
errormessageId: (string | Signal<string>)
The actual id of the control that should be used in the for attribute of a label.
id?: (string | Signal<(string | undefined)>)
If the control is meant to be used a checkbox. This affects the label positioning.
isFormCheck?: boolean
ID that should be assigned to the label element inside the SiFormItemComponent .

If the target control is not of type input, select or button, it cannot be referenced by a label. Instead, aria-labelledby must be used to create a reference to a label. In such a case, an implementation of SiFormItemControl must provide the id of the label in labelledby . SiFormItemComponent will apply the id to the label so that it can be used inside the control to reference it in the aria-labelledby attribute.

labelledby?: (string | Signal<(string | undefined)> | null)
Properties
key: string
message?: TranslatableString
params: any
Interface for form error mapper. It resolves a key to either a translatable string or function which is called with the validation error for its key and should return a translatable string.
Index signature: [ key: string ]: (string | (error: any) => string | undefined)
Properties
dateFormat?: (TranslatableString | (error: { format: string }) => TranslatableString)
email?: (TranslatableString | (error: { email: boolean }) => TranslatableString)
max?: (TranslatableString | (error: { actual: number, max: number }) => TranslatableString)
maxDate?: (TranslatableString | (error: { actual: Date, max: Date }) => TranslatableString)
maxLength?: (TranslatableString | (error: { actualLength: number, requiredLength: number }) => TranslatableString)
min?: (TranslatableString | (error: { actual: number, min: number }) => TranslatableString)
minDate?: (TranslatableString | (error: { actual: Date, min: Date }) => TranslatableString)
minLength?: (TranslatableString | (error: { actualLength: number, requiredLength: number }) => TranslatableString)
numberFormat?: (TranslatableString | (error: { numberFormat: boolean }) => TranslatableString)
pattern?: (TranslatableString | (error: { pattern: (string | RegExp) }) => TranslatableString)
required?: (TranslatableString | (error: { required: boolean }) => TranslatableString)
requiredTrue?: (TranslatableString | (error: { required: boolean }) => TranslatableString)
The error mapper is used to resolve an angular validation error to a TranslatableString . It will be merged with already existing error mappers.
Parameters
mapper: SiFormValidationErrorMapper

Properties
lgMinimum: number
mdMinimum: number
smMinimum: number
xlMinimum: number
xxlMinimum: number
Constructor
() => {}
Properties
container: (SiFormContainerComponent<{ [ key: string ]: AbstractControl<any, any, any> } }> | null) = ...
control: Signal<(AbstractControl<any, any, any> | null | undefined)> implements SiFormFieldsetControl.control = ...
controlElementRef: Signal<(ElementRef<HTMLElement> | undefined)> = ...
Disables the automatic error printing. Error printing will be enabled by default in v46.
disableErrorPrinting: InputSignalWithTransform<boolean, unknown> = false
errors: WritableSignal<SiFormError[]> implements SiFormFieldsetControl.errors = ...
fieldControl: Signal<(SiFormItemControl | undefined)> = ...
fieldControlNative: WritableSignal<(SiFormItemControl | undefined)> = ...
fieldControlQuery: Signal<(SiFormItemControl | undefined)> = ...
fieldset: (SiFormFieldsetComponent | null) = ...
Maps validation errors of the contained control to custom messages.
formErrorMapper: InputSignal<(SiFormValidationErrorMapper | undefined)> = ...
hasRequiredValidator: WritableSignal<boolean> = ...
The label to be displayed in the form item. It will be translated if a translation key is available.
label: InputSignal<TranslatableString> = ...
A custom width value to be applied to the label. A value of 0 is allowed as well to visually hide away the label area.

Numbers will be converted to pixels. Using numbers is discouraged and might be dropped.

Example:
labelWidth="100px"
labelWidth: InputSignal<(string | number | undefined)> = ...
labelWidthCssVar: Signal<(string | undefined)> = ...
ngControl: Signal<(NgControl | undefined)> = ...
previousErrors?: (ValidationErrors | null)
printErrors: Signal<boolean> = ...
radioGroupName: Signal<(string | undefined)> implements SiFormFieldsetControl.radioGroupName = ...
required: Signal<boolean> implements SiFormFieldsetControl.required = ...
Defines that this form item is required for the overall form to be valid.
requiredInput: InputSignalWithTransform<boolean, unknown> = false
requiredTestControl: FormControl<(string | null)> = ...
requiredValidator: Signal<(RequiredValidator | undefined)> = ...
touched: WritableSignal<boolean> implements SiFormFieldsetControl.touched = ...
validationErrorService: SiFormValidationErrorService = ...
validator?: (ValidatorFn | null)
Accessors
get formItemErrormessageId: (string | null)
get formItemId: (string | null)
get formItemLabelledBy: (string | null)
Methods
A callback method that is invoked immediately after the default change detector has completed checking all of the directive's content.
ngAfterContentChecked: () => void from AfterContentChecked.ngAfterContentChecked
A callback method that is invoked immediately after Angular has completed initialization of all of the directive's content. It is invoked only once when the directive is instantiated.
ngAfterContentInit: () => void from AfterContentInit.ngAfterContentInit
(changes: { control: SimpleChange<Signal<(AbstractControl<any, any, any> | null | undefined)>>, disableErrorPrinting: false, errors: SimpleChange<WritableSignal<SiFormError[]>>, formErrorMapper: SimpleChange<(SiFormValidationErrorMapper | undefined)>, label: SimpleChange<TranslatableString>, labelWidth: SimpleChange<(string | number | undefined)>, ngAfterContentChecked: SimpleChange<() => void>, ngAfterContentInit: SimpleChange<() => void>, ngControl: SimpleChange<Signal<(NgControl | undefined)>>, ngOnChanges: SimpleChange<(changes: { readonly label?: SimpleChange<TranslatableString> | undefined; readonly labelWidth?: SimpleChange<string | number | undefined> | undefined; ... 13 more ...; ngOnDestroy?: SimpleChange<...> | undefined; }) => void>, ngOnDestroy: SimpleChange<() => void>, ngOnInit: SimpleChange<() => void>, radioGroupName: SimpleChange<Signal<(string | undefined)>>, required: SimpleChange<Signal<boolean>>, requiredInput: false, touched: SimpleChange<WritableSignal<boolean>> }) => void from OnChanges.ngOnChanges
A callback method that is invoked immediately after the default change detector has checked data-bound properties if at least one has changed, and before the view and content children are checked.
Parameters
The changed properties.
changes: { control: SimpleChange<Signal<(AbstractControl<any, any, any> | null | undefined)>>, disableErrorPrinting: false, errors: SimpleChange<WritableSignal<SiFormError[]>>, formErrorMapper: SimpleChange<(SiFormValidationErrorMapper | undefined)>, label: SimpleChange<TranslatableString>, labelWidth: SimpleChange<(string | number | undefined)>, ngAfterContentChecked: SimpleChange<() => void>, ngAfterContentInit: SimpleChange<() => void>, ngControl: SimpleChange<Signal<(NgControl | undefined)>>, ngOnChanges: SimpleChange<(changes: { readonly label?: SimpleChange<TranslatableString> | undefined; readonly labelWidth?: SimpleChange<string | number | undefined> | undefined; ... 13 more ...; ngOnDestroy?: SimpleChange<...> | undefined; }) => void>, ngOnDestroy: SimpleChange<() => void>, ngOnInit: SimpleChange<() => void>, radioGroupName: SimpleChange<Signal<(string | undefined)>>, required: SimpleChange<Signal<boolean>>, requiredInput: false, touched: SimpleChange<WritableSignal<boolean>> }
A callback method that performs custom clean-up, invoked immediately before a directive, pipe, or service instance is destroyed.
ngOnDestroy: () => void from OnDestroy.ngOnDestroy
A callback method that is invoked immediately after the default change detector has checked the directive's data-bound properties for the first time, and before any of the view or content children have been checked. It is invoked only once when the directive is instantiated.
ngOnInit: () => void from OnInit.ngOnInit
updateRequiredState: () => void
updateValidationMessages: () => void
<(TControl: { [ K in keyof TControl ]: AbstractControl })>
Class
▶
Deprecated: This component should no longer be used.

When providing a form wide error mapper, use the provideFormValidationErrorMapper .
import { provideFormValidationErrorMapper } form '@siemens/element-ng/forms'

@Component({
  template: `<form>...</form>`
  providers: [provideFormValidationErrorMapper({
    'name.required': 'CUSTOM_REQUIRED_ERROR'
  })]
})
class MyFormComponent {}


When using the column layout, use the form-col-layout classes.

<!-- Responsive column layout -->
<form class="responsive-form-col-layout">...</form>
<!-- Always column layout -->
<form class="form-col-layout">...</form>


For a custom breakpoint use the SCSS mixin:

scss
@use '@siemens/element-theme/src/styles/bootstrap/mixins/form-layout';

// Custom responsive breakpoint
.custom-form-col-layout {
  // Above 400px the column layout is used
  @include form-layout.responsive-form-col-layout(400px);
}
Constructor
() => {}
Properties
The container hosts the form within a siResizeContainer to configure the breakpoint for different screen sizes. Optionally, change the container breakpoints with the contentContainerBreakpoints input.
contentContainerBreakpoints: InputSignal<(Breakpoints | undefined)> = ...
A map the maps from control names of the form to their translate keys. The initial map is empty and the user is responsible to add the required translate keys.
controlNameTranslateKeyMap: InputSignal<Map<string, string>> = new Map<​string, string​>()
In some scenarios, one may not want the form container to be responsible for the layout relevant si-container-[xs|...] classes, but let this be done by a different, nested component, e.g. by a group box. In these cases, the property should be set to true.
disableContainerBreakpoints: InputSignalWithTransform<boolean, unknown> = false
Disables the automatic error printing in all nested SiFormItemComponent . Error printing will be enabled by default in v46.
disableErrorPrinting: InputSignalWithTransform<boolean, unknown> = false
Every validation error has an errorCode. This map holds translate keys for error codes. The keys can be used to display a translated message for each validation error. The defaults old english readable key defaults for the Angular standard validators of the Validators class like min , max or required .

Use the input to set your own translate keys for the form validators you need.

errorCodeTranslateKeyMap: InputSignal<(SiFormValidationErrorMapper | Map<string, string> | undefined)> = ...
Set the form entity to the container to enable the overall form validation on in the form container edit panel.
form: InputSignal<(FormGroup<TControl> | undefined)> = ...
formErrorMapper: Signal<{ [ key: string ]: (string | (error: any) => string | undefined) } }> = ...
hasParentContainer: boolean = ...
A custom width value to be applied to all labels.

Example:
labelWidth="100px".
labelWidth: InputSignal<(string | undefined)> = ...
A form container in readonly mode is only displaying the form content without ability to change it. The edit panel with typically save and cancel buttons is hidden. Set to true to display the edit panel.
readonly: InputSignalWithTransform<boolean, unknown> = false
Accessors
Indicates whether the content editor message shall be styled as warning.
Returns true , if SiFormContainerComponent.userInteractedWithForm is true and the form is invalid.

get invalidFormContainerMessage: boolean
Indicates whether the user interacted with the form.
Returns true , if the user selected at least one form element and [blurred] https://developer.mozilla.org/en-US/docs/Web/API/Element/blur_event by losing focus again (e.g. by setting focus on another element), or by editing the content of a form element. Otherwise false .

get userInteractedWithForm: boolean
Indicates whether content editor message shall be styled as success.
Returns true , if SiFormContainerComponent.userInteractedWithForm is true and the form is valid.

get validFormContainerMessage: boolean
Methods
Parameters
controlName: string
Constructor
() => {}
Properties
errors: Signal<readonly SiFormError[]> = ...
formItems: WritableSignal<SiFormFieldsetControl[]> = ...
hasOnlyRadios: Signal<boolean> = ...
Switches all child inputs to inline mode
inline: InputSignalWithTransform<boolean, unknown> = false
isRequired: Signal<boolean> = ...
The label for the entire fieldset.
label: InputSignal<TranslatableString> = ...
labelId: string = ...
Overrides the parent label width.
labelWidth: InputSignal<(string | undefined)> = ...
Adds a required marker to the label
required: InputSignalWithTransform<boolean, unknown> = false
showErrors: Signal<boolean> = ...
labelIdCounter: number = 0
Methods
(item: SiFormFieldsetControl) => void
Parameters
item: SiFormFieldsetControl
(item: SiFormFieldsetControl) => void
Parameters
item: SiFormFieldsetControl

Except where otherwise noted, content on this site is licensed under MIT License.