Skip to content

Duration Picker for Angular

AngularForm Inputs

Enter a fixed-length, non-negative Duration (milliseconds) in contiguous unit segments (days, hours, minutes, seconds; default hours and minutes) inside a labelled group. Each segment is a spinbutton with localized unit text; ArrowUp/ArrowDown change the total and carry between units, with min, max, and step validation and native form submission as an ISO 8601 duration (PT1H30M).

  • Choose the unitsAny combination of days, hours, minutes, and seconds fields.
  • Steps and limitsMinimum, maximum, and a step that values snap to.
  • Exact durationsReturns a fixed-length duration in milliseconds, never an ambiguous string.
  • Form readyValidation, custom errors, and native form submission.

Behavior, design tokens, and limitations are described on the Duration Picker page; this page covers the Angular API.

import { Component } from '@angular/core';
import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
import { duration, type Duration } from '@absoluteui/core';
import { AuiDurationPicker } from '@absoluteui/angular/duration-picker';
@Component({
selector: 'app-task-estimate',
imports: [ReactiveFormsModule, AuiDurationPicker],
template: `<aui-duration-picker label="Estimate" [max]="max" [step]="step" [required]="true" [formControl]="estimate"></aui-duration-picker>`,
})
export class TaskEstimateComponent {
readonly max = duration(8 * 3_600_000);
readonly step = duration(15 * 60_000);
readonly estimate = new FormControl<Duration | null>(null, { validators: [Validators.required] });
}
Terminal window
npm install @absoluteui/angular @absoluteui/components @absoluteui/core @absoluteui/theme

Setup with provideAbsoluteUI() is covered in Getting started. Styles are included with the component.

import { AuiDurationPicker } from '@absoluteui/angular/duration-picker';

Defaults for every instance: provideAbsoluteUIConfig({ components: { durationPicker: { ... } } }) (see Configuration).

Class AuiDurationPicker; template reference #ref="auiDurationPicker".

Server rendering: Renders on the server; the browser re-creates it after hydration.

Angular forms: implements ControlValueAccessor and Validator; the form value is Duration \| null. Bind [formControl], formControlName, or [(ngModel)]; validation messages of the component report through the aui error key. See Forms.

Input Type Default Description
label string Required. Visible label and accessible name of the group (via aria-labelledby).
hideLabel boolean false Visually hide the label; it remains the accessible name.
min Duration | null null Inclusive lower bound for validation and stepping (non-negative). Stepping stops at zero when unset. Must not exceed max.
max Duration | null null Inclusive upper bound for validation and stepping (non-negative); also sets the digits and aria-valuemax of the largest segment.
step Duration 'one of the smallest unit' Increment of the smallest segment and the valid-value grid from zero. Positive and a whole number of the smallest unit.
name string Form field name for the hidden input (ISO 8601 duration, for example PT1H30M).
description string Help text referenced by the group’s aria-describedby.
required boolean false An empty entry is invalid; segments are required and the required indicator is shown.
disabled boolean false Disables the segments; not submitted.
readOnly boolean false Focusable and submitted; not editable, and stepping, Home/End, and separators are ignored.
validate (value: Duration | null) => string | null Consumer validation after built-in checks; return a message to mark the value invalid.
icons Partial<DurationPickerIcons> Icon slot overrides.
validationTiming ValidationTiming 'blur' When validation messages first appear; afterwards they update live.
fields readonly DurationField[] 'hours,minutes' Unit segments, largest first, as a contiguous non-empty run of ‘days’ | ‘hours’ | ‘minutes’ | ‘seconds’.
locale string 'en-US' Segment names, unit text and its position, aria-valuetext, durations in messages, and messages.
direction "ltr" | "rtl" 'ltr' Direction of the group; ArrowLeft/ArrowRight follow it.
Model Type Change output Description
[(value)] Duration | null (valueChange) The value: [(value)] without forms; with Angular forms, bind the form control instead.
Output Payload Description
(changed) DurationPickerChangeDetail The user changed the value or its validity error (typing, stepping, Home/End, or a separator). Re-emits aui-change.

Call them through a viewChild query or a template reference.

Method Description
reportValidity(): boolean | undefined Show messages now and return validity.
setCustomError(message: string | null): void External error (server, cross-field rule); cleared when the user edits.
getFormValue(): string | null | undefined ISO 8601 duration in hours, minutes, and seconds (PT1H30M), or null when empty or invalid.
focus(): void Focus the first (largest) segment.
reset(): void Restore the initial value and clear dirty/touched/submitted state (no events).

Pattern: Labelled group of WAI-ARIA APG Spinbutton segments (one text input per unit) with no popup; each segment exposes its unit value and a localized value text.

The Angular component renders the framework-neutral component, so its keyboard support, roles, WCAG 2.2 criteria, budgets, and import cost apply unchanged: see Duration Picker: Accessibility and performance.