Time Input

A time typed part by part — hour, minute, second, AM/PM — on the clock and in the order of its locale. Each part is an input: a number pad on a phone, digits that move on by themselves, arrows that step. In a form, a Temporal.PlainTime.

FormsExperimental

Usage

Usage

In your local time.

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScField,  ScFieldDescription,  ScLabel,  ScTimeInput,} from '@semantic-components/ui';
/** A time in a field: named by its label, described by its description. */@Component({

Anatomy

One part, in a field: it writes its own parts from the locale — their order, the text between them, its clock — so there is nothing to put inside it. The label, the description and the errors are the field's.

import { ScField, ScFieldDescription, ScLabel, ScTimeInput } from '@semantic-components/ui';
<div scField>  <label scLabel>Meeting time</label>  <div scTimeInput [formField]="form.time"></div>  <p scFieldDescription>In your local time.</p></div>

The value

A Temporal.PlainTime, through [formField] or [(value)]: null until every part is filled, and again when one is emptied. Whatever clock shows, the value is the day's time (14:30). A whole time pasted — 14:30, 2:30 PM — fills every part.

Keyboard

KeyDoes
Digits Fill the part; on to the next once no digit can follow (9, 30)
A / PAM / PM, on a 12-hour clock
↑ / ↓ One up or down, wrapping; an empty part starts at now
Page Up / Page Down A bigger step: hours by 2, minutes and seconds by 15
Home / EndThe part's lowest / highest
Backspace A digit back, then the part emptied, then the part before
DeleteEmpties the part
← / →The part to the left / right, as they show
:, TabThe next part (Tab: then out)

Accessibility

  • A group, named by the field's label; each part a spin button named in the locale's words (hour, minute, AM/PM), with its value, its range and its text; the field's description is read with it.
  • Each part is an input: the number pad on a phone, a part to tap.
  • Out of its limits, or invalid once left: every part is marked invalid; the message is the field's.
  • Right to left, the clock's digits stay left to right; the arrows follow the parts as they show.

Examples

Hour cycle

import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScField, ScLabel, ScTimeInput } from '@semantic-components/ui';
/** The locale's clock by default; 12 or 24 hours, seconds, the hour in two digits. */@Component({  selector: 'app-hour-cycle-time-input-demo',  imports: [ScField, ScLabel, ScTimeInput],  template: `    <div class="grid w-full max-w-md grid-cols-1 gap-4 sm:grid-cols-2">      <div scField>

Limits

Between 9:00 AM and 5:30 PM.

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScField,  ScFieldDescription,  ScLabel,  ScTimeInput,} from '@semantic-components/ui';
/** minTime and maxTime: a time outside them is marked invalid. */@Component({

Locale

import {  Component,  HostAttributeToken,  LOCALE_ID,  ViewEncapsulation,  inject,  input,  model,  signal,} from '@angular/core';

Disabled

import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScField, ScLabel, ScTimeInput } from '@semantic-components/ui';
/** Disabled: its parts leave the tab order. */@Component({  selector: 'app-disabled-time-input-demo',  imports: [ScField, ScLabel, ScTimeInput],  template: `    <div scField class="w-44">      <label scLabel>Start time</label>

Read-only

import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScField, ScLabel, ScTimeInput } from '@semantic-components/ui';
/** Read-only: its parts can be focused and read, not changed. */@Component({  selector: 'app-read-only-time-input-demo',  imports: [ScField, ScLabel, ScTimeInput],  template: `    <div scField class="w-44">      <label scLabel>Signed at</label>

Form

9:00 AM to 5:00 PM, every 15 minutes.

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  FormField,  FormRoot,  form,  required,  validate,} from '@angular/forms/signals';import {  ScButton,

Controlled

Reminder at 07:45

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScButton,  ScField,  ScLabel,  ScTimeInput,} from '@semantic-components/ui';
/** Its value in a signal, two-way; clear() empties every part. */@Component({

RTL

بتوقيتك المحلي.

import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation, signal } from '@angular/core';import {  ScField,  ScFieldDescription,  ScLabel,  ScTimeInput,} from '@semantic-components/ui';
/** In a right-to-left page: the clock's digits stay left to right, AM/PM on the side the locale puts it; the arrows follow the parts as they show. */

API reference

It takes class, merged over its own (cn: a later class wins); its look is the style's input.

PartSelectorDescription
ScTimeInputdiv[scTimeInput] The group, its parts written from the locale: an input each (role spinbutton). data-empty, data-invalid, data-disabled, data-readonly; on a part, data-type and data-empty. exportAs scTimeInput: clear(), focus(options, part), segments(), twelveHours().
ScDateTimeSegmentinput[scDateTimeSegment] A part: an input (spin button) the time input writes, one per part, from the locale — not one to place or style yourself; its look is the style's (segmentedInput.segment). data-type, data-empty. exportAs scDateTimeSegment: text().
InputTypeDefaultDescription
valueTemporal.PlainTime | nullnull Two-way, or [formField]: null until every part is filled.
hourCycle12 | 24the locale's A 12-hour clock (with AM/PM), or 24.
granularity'hour' | 'minute' | 'second''minute' The smallest part it shows.
leadingZerosbooleanfalse The hour always in two digits (09); else the locale's way.
minTime, maxTimeTemporal.PlainTime— A time outside them is marked invalid.
disabled, readonly, required, invalid, touchedbooleanfalse Bound by [formField]: from the schema and its state.