Time Clock
A time picked on a clock face — the hour, then the minute, then the second — by pointer or keyboard, each pick moving on to the next. The locale's numbers, 12 hours with AM/PM or 24 on two rings. In a form, a Temporal.PlainTime.
Usage
Usage
10:30:00
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScTimeClock, ScTimeClockDial, ScTimeClockHeader,} from '@semantic-components/ui';
/** The hour, then the minute: drag or click the hand, or the keyboard on the dial (arrows, Page Up/Down, Home/End, Enter). The header shows the time and switches the view; AM and PM in 12 hours. */@Component({ selector: 'app-basic-time-clock-demo',Anatomy
The clock holds two parts that write their own content: the header — the time, each part a button for its view, AM/PM in 12 hours — and the dial, a slider you name by view.
import { ScTimeClock, ScTimeClockDial, ScTimeClockHeader } from '@semantic-components/ui';<div scTimeClock #clock="scTimeClock" [formField]="form.at"> <div scTimeClockHeader></div> <div scTimeClockDial [attr.aria-label]="clock.names()[clock.view()]"></div></div>Picking
Drag or click the hand to an hour; let go, and the dial moves on to the minutes — then the seconds, with granularity="second". As in every picker, each pick moves on to the next part; the header's buttons go back to any view. An empty clock starts at now. Outside minTime / maxTime, the numbers are dimmed and can't be picked.
Keyboard
| Key | Does (on the dial) |
|---|---|
| ↑→ / ↓← | One hour, or one step of minutes or seconds |
| Page Up / Page Down | Hours by 2, minutes and seconds by 15 — as the Time Input |
| Home / End | The first / last value |
| Enter | On to the next view |
Accessibility
- The dial is a slider (role slider): its value the hour, minute or second, its text the whole time as the locale writes it. Name it by view.
- The header's buttons are named in the locale's words and pressed while their view shows; AM and PM are pressed while theirs.
- The numbers on the face are decorative; right to left, the face never turns, and the header's time stays left to right.
Examples
24 hours
18:45:00
import { Component, LOCALE_ID, ViewEncapsulation, signal } from '@angular/core';import { ScTimeClock, ScTimeClockDial, ScTimeClockHeader,} from '@semantic-components/ui';
/** LOCALE_ID provided as 'fr-FR': 24 hours — 13 to 00 on an inner ring. hourCycle overrides the locale’s 12 or 24. */@Component({ selector: 'app-locale-time-clock-demo',Seconds
10:30:00
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScTimeClock, ScTimeClockDial, ScTimeClockHeader,} from '@semantic-components/ui';
/** granularity="second", 24 hours: hours, minutes, then seconds — each pick moves on to the next; seconds every 5. */@Component({ selector: 'app-seconds-time-clock-demo',Step
No time.
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScTimeClock, ScTimeClockDial, ScTimeClockHeader,} from '@semantic-components/ui';
/** minuteStep: 5 minutes — the hand snaps to them, the arrows move by them. */@Component({ selector: 'app-step-time-clock-demo',Limits
09:00:00
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScTimeClock, ScTimeClockDial, ScTimeClockHeader,} from '@semantic-components/ui';
/** minTime and maxTime: the hours and minutes outside them are dimmed and cannot be picked. Here, 9:00 to 17:30, every quarter hour. */@Component({ selector: 'app-limits-time-clock-demo',With a time input
07:15:00
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScField, ScLabel, ScTimeClock, ScTimeClockDial, ScTimeClockHeader, ScTimeInput,} from '@semantic-components/ui';In a form
import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, FormRoot, form, required } from '@angular/forms/signals';import { ScButton, ScField, ScFieldErrors, ScTimeClock, ScTimeClockDial, ScTimeClockHeader,} from '@semantic-components/ui';RTL
10:30:00
import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation, signal } from '@angular/core';import { ScTimeClock, ScTimeClockDial, ScTimeClockHeader,} from '@semantic-components/ui';
/** In a right-to-left page: the numbers are the locale's, the face never turns (a clock is a clock), the header's time stays left to right; AM/PM in Arabic. */@Component({API reference
Each part takes class, merged over its own (cn: a later class wins); the face's size and the text sizes are the style's (timeClock).
| Part | Selector | Description |
|---|---|---|
ScTimeClock | div[scTimeClock] | The root: the value and the view. exportAs scTimeClock: views(), names(), text(), partText(view), period(), setHour/Minute/Second(), setPeriod(), moveOn(). |
ScTimeClockHeader | div[scTimeClockHeader] | The time, each part a button for its view (aria-pressed), AM/PM in 12 hours. Writes its own content. |
ScTimeClockDial | div[scTimeClockDial] | The face: a slider; its size and numbers the style's (timeClock). Writes its own content; name it by view. |
| Input | Type | Default | Description |
|---|---|---|---|
value | Temporal.PlainTime | null | null | Two-way, or [formField]. |
view | 'hours' | 'minutes' | 'seconds' | 'hours' | Two-way: what the dial shows; each pick moves on. |
hourCycle | 12 | 24 | the locale's | 12 hours with AM/PM, or 24 on two rings. |
granularity | 'hour' | 'minute' | 'second' | 'minute' | The smallest part it picks: its views. |
minuteStep, secondStep | number | 1 | The minutes and seconds that can be picked. |
minTime, maxTime | Temporal.PlainTime | — | Outside them, dimmed and not picked. |
disabled, readonly, invalid, touched | boolean | false | Bound by [formField]. |