Skip to content

Vue Package

The Vue package provides Vue components for rendering clocks in Vue applications.

Installation

bash
# npm
npm install @clock-ui/vue

# yarn
yarn add @clock-ui/vue

# pnpm
pnpm add @clock-ui/vue

# bun
bun add @clock-ui/vue

Usage

BaseClock

Display a static clock at a specific time.

vue
<template>
  <BaseClock :hours="10" :minutes="30" :seconds="45" />
</template>

<script setup>
import { BaseClock } from "@clock-ui/vue";
import "@clock-ui/vue/base.css";
</script>

LiveClock

Display a live clock that updates in real-time.

vue
<template>
  <LiveClock :smooth-sweep="true" timezone="America/New_York" />
</template>

<script setup>
import { LiveClock } from "@clock-ui/vue";
import "@clock-ui/vue/base.css";
</script>

Props

Shared

Both components accept these:

PropTypeDefaultDescription
useRomanbooleanfalseRoman numerals instead of Arabic. These are oriented radially, pointing outward from the centre, so the lower numerals read upside down. That is deliberate — it is how roman dials have always been set — and it is why Arabic numerals stay upright while these do not.
cardinalOnlybooleanfalseShow only 12, 3, 6, and 9.
hideNumbersbooleanfalseHide all numerals.
hideTicksbooleanfalseHide all tick marks.
hideMajorTicksbooleanfalseHide the five-minute ticks.
hideMinorTicksbooleanfalseHide the single-minute ticks.
hideSecondsbooleanfalseHide the second hand.
noBorderbooleanfalseDrop the outer frame.
dualTonebooleantrueTwo-tone hands for contrast against the face.

BaseClock

PropTypeDefaultDescription
hoursnumberRequired. 0–23.
minutesnumberRequired. 0–59.
secondsnumber00–59.
millisecondsnumber00–999. Drives sub-second hand position.
Use the #info slot for the info window instead.

LiveClock

Takes the shared props plus:

PropTypeDefaultDescription
smoothSweepbooleanfalseContinuous sweep instead of ticking. Ignored under prefers-reduced-motion.
timezonestringIANA name, e.g. "Asia/Tokyo". Defaults to local time. Invalid names fall back to local.
hideDatebooleanfalseHide the date window.
tickDurationnumber600How long the second hand takes to swing to each new mark, in milliseconds. 0 snaps with no swing. Ignored in sweep mode.

LiveClock reads the clock itself, so it takes no hours/minutes.

Types

Prop types are exported if you need to wrap the components:

ts
import type {
  CommonClockProps,
  BaseClockProps,
  LiveClockProps,
} from "@clock-ui/vue";

Slots

BaseClock exposes one named slot, info, rendered in the small window on the face. LiveClock fills it with the day of the month unless hideDate is set.

vue
<BaseClock :hours="10" :minutes="9">
  <template #info>SUN</template>
</BaseClock>

Vue props are kebab-case in templates: smooth-sweep, use-roman, cardinal-only, hide-major-ticks, and so on.

Released under the MIT License.