ngx-analog-clock

December 17, 2025 ยท View on GitHub

A beautiful, customizable analog clock component for Angular applications with timezone support, custom themes, and extensive styling options.

npm version License: MIT

๐ŸŽจ Demo

Live Demo & Interactive Playground

Explore pre-built designs and create your own custom clock with our interactive playground.

โœจ Features

  • ๐ŸŽจ Multiple Themes - Light, Dark, and fully Custom themes
  • ๐ŸŒ Timezone Support - Display time from any timezone using IANA strings
  • โฑ๏ธ Custom Time Control - Perfect for timers and countdowns
  • ๐ŸŽจ Full Customization - Colors, gradients, sizes, and styles
  • ๐Ÿ“ฑ Responsive - Works seamlessly on all screen sizes
  • โšก Smooth Animations - 30 FPS second hand movement
  • ๐ŸŽฏ TypeScript - Full type definitions included
  • ๐Ÿ“ฆ Lightweight - Optimized performance with minimal bundle size

๐Ÿ“ฆ Installation

npm install @craftedcode-dev/ngx-analog-clock

๐Ÿš€ Quick Start

1. Import the component:

import { Component } from '@angular/core';
import { AnalogClockComponent } from '@craftedcode-dev/ngx-analog-clock';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [AnalogClockComponent],
  template: '<ngx-analog-clock></ngx-analog-clock>'
})
export class AppComponent {}

2. Basic customization:

import { AnalogClockConfig } from '@craftedcode-dev/ngx-analog-clock';

export class MyComponent {
  clockConfig: AnalogClockConfig = {
    size: 300,
    theme: 'dark'
  };
}
<ngx-analog-clock [config]="clockConfig"></ngx-analog-clock>

๐Ÿ“š API Reference

Basic Configuration

PropertyTypeDefaultDescription
sizenumber300Clock diameter in pixels
theme'light' | 'dark' | 'custom''light'Pre-built theme or custom for full control
timezonestring'local'IANA timezone string (e.g., 'America/New_York')
timeDateundefinedCustom time to display (for timers/countdowns)

Hands Configuration

Configure via config.hands:

PropertyTypeDefaultDescription
hour.lengthnumber0.55Length as fraction of radius (0.1-0.9)
hour.widthnumber6Width in pixels
hour.showbooleantrueShow/hide hour hand
minute.lengthnumber0.7Length as fraction of radius (0.1-0.9)
minute.widthnumber6Width in pixels
minute.showbooleantrueShow/hide minute hand
second.lengthnumber0.8Length as fraction of radius (0.1-0.9)
second.widthnumber4Width in pixels
second.showbooleantrueShow/hide second hand
smoothbooleantrueEnable smooth animation

Display Configuration

Configure via config.display:

PropertyTypeDefaultDescription
markers'lines' | 'numbers' | 'dots' | 'lines-numbers' | 'dots-numbers' | 'none''lines'Hour markers: lines (traditional), dots (circular), numbers (1-12), lines-numbers (lines + cardinal numbers), dots-numbers (dots + cardinal numbers), or none
numberStyle'arabic' | 'roman''arabic'Number style: Arabic (1-12) or Roman numerals (I-XII)
showBorderbooleantrueShow clock border
showInnerRingbooleantrueShow inner decorative ring
showCenterRingbooleantrueShow ring around center
hourMarkerWidthnumber3Size of hour markers in pixels. Works for both lines (stroke width) and dots (radius)
minuteMarkerWidthnumber1Size of minute markers in pixels. Works for both lines (stroke width) and dots (radius)
borderWidthnumber10Border width in pixels
numberSizenumber16Font size for numbers
numberWeight'light' | 'normal' | 'bold''bold'Font weight for numbers

Custom Colors

Configure via config.customColors (only applies when theme is 'custom'):

PropertyTypeDescription
hands.hourstringHour hand color
hands.minutestringMinute hand color
hands.secondstringSecond hand color
markers.hourstringHour markers color (works for both line and dot markers)
markers.minutestringMinute markers color (works for both line and dot markers)
markers.numbersstringNumbers color
center.dotstringCenter dot color
center.ringstringCenter ring color
backgroundstringClock face background
borderstringClock border color
innerRingstringInner ring color
labelstringLabel text color

Gradient Backgrounds

Configure via config.customColors.backgroundGradient:

PropertyTypeDefaultDescription
type'linear' | 'radial'-Gradient type
startstring-Start color
endstring-End color
anglenumber45Angle in degrees (linear only)

Digital Display

Configure via config.digitalDisplay:

PropertyTypeDefaultDescription
enabledbooleanfalseShow digital time display
format'12h' | '24h''24h'Time format
showSecondsbooleantrueShow seconds in digital display
showDatebooleanfalseShow date in digital display
colorstringtheme-dependentCustom color for digital display text

Label

Configure via config.label:

PropertyTypeDefaultDescription
textstring-Label text (e.g., timezone name)
position'top' | 'bottom''bottom'Label position

๐Ÿ’ก Usage Examples

Timezone Clock

clockConfig: AnalogClockConfig = {
  size: 250,
  timezone: 'America/New_York',
  label: {
    text: 'New York',
    position: 'bottom'
  },
  digitalDisplay: {
    enabled: true,
    format: '12h'
  }
};

Modern Dot Markers

clockConfig: AnalogClockConfig = {
  size: 250,
  theme: 'custom',
  display: {
    markers: 'dots-numbers',
    hourMarkerWidth: 5,
    numberWeight: 'bold'
  },
  customColors: {
    background: '#f0f9ff',
    border: '#0ea5e9',
    hands: {
      hour: '#0c4a6e',
      minute: '#0369a1',
      second: '#e11d48'
    },
    markers: {
      hour: '#075985',
      numbers: '#0c4a6e'
    }
  }
};

Custom Theme

clockConfig: AnalogClockConfig = {
  theme: 'custom',
  customColors: {
    hands: {
      hour: '#3b82f6',
      minute: '#60a5fa',
      second: '#93c5fd'
    },
    markers: {
      hour: '#1e40af',
      minute: '#3b82f6'
    },
    background: '#ffffff',
    border: '#e0e7ff'
  }
};

Gradient Background

clockConfig: AnalogClockConfig = {
  theme: 'custom',
  customColors: {
    backgroundGradient: {
      type: 'radial',
      start: '#667eea',
      end: '#764ba2'
    },
    hands: {
      hour: '#ffffff',
      minute: '#ffffff',
      second: '#fbbf24'
    }
  }
};

Timer/Countdown

export class TimerComponent implements OnInit {
  customTime: Date = new Date();
  
  clockConfig: AnalogClockConfig = {
    size: 300,
    theme: 'dark'
  };

  ngOnInit() {
    // Update every second
    setInterval(() => {
      this.customTime = new Date(this.customTime.getTime() + 1000);
    }, 1000);
  }
}
<ngx-analog-clock 
  [time]="customTime" 
  [config]="clockConfig">
</ngx-analog-clock>

๐Ÿ“– Documentation

For detailed documentation, interactive examples, and the playground, visit:

Full Documentation

๐Ÿ› ๏ธ Requirements

  • Angular 17+
  • TypeScript 5.0+

๐Ÿ“„ License

MIT ยฉ 2025 craftedcode-dev