Countdown
The time left until a moment, in tiles or in words, named in the reader’s language and announced to a screen reader without a word every second.
Import
import { Countdown } from '@vitral/vue';Basic
`to` is a Date, an ISO string or a timestamp. The unit names come from the browser, in the locale's language, and a leading unit at zero is left out.
Words, units and a pause
`variant="text"` writes it as a line. `units` picks what to count in — here minutes and seconds only, so an hour and a half reads 90 minutes. `paused` stops the clock where it is, and `end` fires when it gets there.
The session ends in .
Drawn your own way
The default slot is given what is left and whether it is over, and draws the rest itself.
API
Read from packages/vue/src/components/Countdown/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| to * | Date | string | number | The moment to count to: a Date, an ISO string or a timestamp. |
| units | CountdownUnit[] | The units to show, largest first. Defaults to days, hours, minutes and seconds. |
| variant | 'tiles' | 'text' | Tiles, or a line of words. Defaults to `'tiles'`. |
| hideLeadingZeros | boolean | Leave out the leading units that are at zero: no "0 days" a day before. Defaults to true. |
| paused | boolean | Stops the clock where it is. |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| end | — | The moment arrived. |
Slots
| Name | Slot props | Description |
|---|---|---|
| default | (context: { days: number; hours: number; minutes: number; seconds: number; done: boolean }) | Replaces the whole drawing: given what is left. |