Check out the live demo to see all modes in action.
A beautiful 3D flip clock component for Vue 3 with smooth animations and multiple modes.
- 🎯 Three Modes: Clock, Countdown, and Timer
- 🎨 Smooth 3D Animations: Realistic flip card animations
- 📦 Lightweight: Minimal dependencies
- 🔧 Easy to Use: Simple API with Vue 3 Composition API
- 💪 TypeScript Support: Full type hints via JSDoc
- 🎭 Customizable: SCSS styling that can be themed
npm install @xiaxiangfeng/vue-flip-clockOr with yarn:
yarn add @xiaxiangfeng/vue-flip-clockOr with pnpm:
pnpm add @xiaxiangfeng/vue-flip-clockimport { createApp } from 'vue'
import VueFlipClock from '@xiaxiangfeng/vue-flip-clock'
import '@xiaxiangfeng/vue-flip-clock/dist/style.css'
const app = createApp(App)
app.use(VueFlipClock)
app.mount('#app')Then use it in your template:
<template>
<FlipClock />
</template><template>
<FlipClock mode="countdown" :value="targetTime" />
</template>
<script setup>
import { FlipClock } from '@xiaxiangfeng/vue-flip-clock'
import '@xiaxiangfeng/vue-flip-clock/dist/style.css'
const targetTime = Date.now() + 60 * 60 * 1000 // 1 hour from now
</script>Display current time:
<FlipClock />Countdown to a specific time:
<script setup>
import { FlipClock } from '@xiaxiangfeng/vue-flip-clock'
// Countdown to a specific date
const targetDate = new Date('2024-12-31T23:59:59').getTime()
// Or countdown 1 hour from now
const oneHourLater = Date.now() + 60 * 60 * 1000
</script>
<template>
<FlipClock mode="countdown" :value="targetDate" />
</template>Count up from a start time:
<script setup>
import { FlipClock } from '@xiaxiangfeng/vue-flip-clock'
// Timer started 5 minutes ago
const startTime = Date.now() - 5 * 60 * 1000
</script>
<template>
<FlipClock mode="timer" :value="startTime" />
</template>| Prop | Type | Default | Description |
|---|---|---|---|
mode |
'clock' | 'countdown' | 'timer' |
'clock' |
Display mode of the flip clock |
value |
Date | number |
Date.now() |
Reference time (timestamp or Date object) |
- clock: Displays current time (HH:MM:SS).
valueprop is ignored. - countdown: Counts down to the target time specified in
value. Stops at 00:00:00. - timer: Counts up from the start time specified in
value.
The component uses SCSS for styling. You can customize the appearance by overriding CSS variables or classes:
.flip-clock-wrapper {
/* Customize size */
--flip-width: 60px;
--flip-height: 90px;
--flip-font-size: 80px;
}
.flip-clock-wrapper .inn {
/* Customize colors */
background-color: #502d2d;
color: #ccc;
}Check out the live demo to see all modes in action.
- Vue 3.5.0 or higher
# Clone the repository
git clone https://github.com/xiaxiangfeng/vue-flip-clock.git
cd vue-flip-clock
# Install dependencies
npm install
# Start dev server for demo
npm run dev
# Build library
npm run build
# Build demo
npm run build:demovue-flip-clock/
├── lib/ # Component library source
│ ├── FlipClock.vue
│ ├── components/
│ └── index.js
├── demo/ # Demo application
│ ├── App.vue
│ └── main.js
├── dist/ # Build output (library)
└── dist-demo/ # Build output (demo)
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT © Your Name
- Inspired by classic flip clocks
- Built with Vue 3 and Vite
Note: Replace xiaxiangfeng in URLs with your actual GitHub username before publishing.