ngx-analog-clock

February 1, 2026 ยท View on GitHub

Analog Clock animation

ngx-analog-clock

npm version npm downloads GitHub license

Angular library for easier use of the View Transitions API

Demo

https://derstimmler.github.io/ngx-analog-clock/

Installation

Available on npm.

npm install ngx-analog-clock

Required Angular version: >=19.0.0

Usage

Import the component:

import { NgxAnalogClock } from 'ngx-analog-clock';

date = new Date();

Provide at least a Date object to the component:

<ngx-analog-clock [date]="date"></ngx-analog-clock>

Tip

To get a Date signal of the current local time that updates every second you can use this snippet:

import { toSignal } from '@angular/core/rxjs-interop';
import { map, interval } from 'rxjs';

date = toSignal(interval(1000).pipe(map(() => new Date())), { initialValue: new Date() });

Configuration

InputDescriptionDefault Value
dateCurrent date/time driving the clockRequired
showHourHandToggle visibility of the hour handtrue
showMinuteHandToggle visibility of the minute handtrue
showSecondHandToggle visibility of the second handtrue
showHourMarkersShow hour tick markerstrue
showMinuteMarkersShow minute tick markerstrue
showClockNumbersDisplay clock face numberstrue
showBezelShow outer bezel (rim)true
transitionDurationDuration of hand movement transitions'0.5s'
transitionFunctionCSS transition timing function for hand movement'cubic-bezier(0.4, 2, 0.3, 1)'
bezelThicknessThickness of the bezel'3px'
pivotThicknessSize of the pivot (center cap)'12px'
hourHandThicknessThickness of the hour hand'9px'
hourHandLengthLength of the hour hand relative to radius'60%'
minuteHandThicknessThickness of the minute hand'6px'
minuteHandLengthLength of the minute hand relative to radius'90%'
secondHandThicknessThickness of the second hand'3px'
secondHandLengthLength of the second hand relative to radius'97%'
pivotColorColor of the pivot'#ff0000'
hourHandColorColor of the hour hand'#222222'
minuteHandColorColor of the minute hand'#222222'
secondHandColorColor of the second hand'#222222'
hourMarkerColorColor of the hour markers'#222222'
minuteMarkerColorColor of the minute markers'#222222'
clockNumberColorColor of the numbers'#222222'
dialColorBackground color of the clock face'transparent'
bezelColorColor of the bezel'#222222'
markerOffsetPercentRadial offset for markers (relative to radius)96
numbersOffsetPercentRadial offset for numbers (relative to radius)70
hourMarkerThicknessThickness of hour markers'2%'
hourMarkerLengthLength of hour markers'7%'
minuteMarkerThicknessThickness of minute markers'1%'
minuteMarkerLengthLength of minute markers'3%'
hourHandBorderRadiusBorder radius of the hour hand'2px'
minuteHandBorderRadiusBorder radius of the minute hand'2px'
secondHandBorderRadiusBorder radius of the second hand'2px'
minuteMarkerBorderRadiusBorder radius of minute markers'2px'
hourMarkerBorderRadiusBorder radius of hour markers'2px'

Most color inputs like dialColor, minuteHandColor or hourMarkerColor are implemented as CSS background property. So it's also possible to use gradient or even images.

Responsiveness

The component behaves like a normal block element and scales dynamically. So just set the width and height as you like.