Skip to content
weftGitHub

Countdown

Days, hours, minutes and seconds to a moment.

SourcePackage @weft-js/warp

Preview

tsx
import { Countdown, Stack, Text } from '@weft-js/warp'export function Freeze() {  const to = Date.now() + 2 * 3600_000 + 14 * 60_000  return (    <Stack gap="related" align="center">      <Text role="label">Deploy freeze starts in</Text>      <Countdown to={to} label="Deploy freeze starts in" />    </Stack>  )}

Installation

npm install @weft-js/warp

Usage

tsx
import { Countdown } from '@weft-js/warp'

Accessibility

  • It is a timer with live updates off, and it is announced once, at one minute.

API Reference

PropTypeDefaultDescription
tonumber—The moment, in epoch ms.
nownumber—The time now, to render on the server. Without it the digits fill in after mount.
labelstring'Starts in'Its accessible name.
EventTypeDefaultDescription
onDone(() => void)—It reached zero.

Parts

Every element carries a stable name, so you can style it from your own CSS: [data-scope="countdown"] [data-part="countdown"]

countdown

RelatedScheduled lobby