@molecule/app-countdown-solid
Feature · countdown · App (browser) · v1.1.1 · Apache-2.0
useCountdown hook + Countdown component for time-to-event displays
npm install @molecule/app-countdown-solidHow it works
@molecule/app-countdown-solid is a ready-made countdown feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { Countdown } from '@molecule/app-countdown-solid'
export function Sale() {
return (
<Countdown
// Compact default: "3d 4h 12m 5s"
target="2026-12-31T23:59:59Z"
expired={<span>Sale ended!</span>}
/>
)
}
// Colon format: "03:04:12:05"
<Countdown target={new Date('2026-12-31')} format="colon" />
// Long format: "3 days 4 hours 12 minutes 5 seconds"
<Countdown target={Date.now() + 3_600_000} format="long" />Works with: @molecule/app-solid, @molecule/app-ui, @molecule/app-ui-solid
Reference
Solid time-remaining countdown — the counterpart of
@molecule/app-countdown-react: the same exports, the same props (React
names) and the same DOM for the same input.
Exports:
useCountdown(target, tickMs?)— live state primitive.<Countdown>— display component with compact/long/colon formats and custom render.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { Countdown } from '@molecule/app-countdown-solid'
export function Sale() {
return (
<Countdown
// Compact default: "3d 4h 12m 5s"
target="2026-12-31T23:59:59Z"
expired={<span>Sale ended!</span>}
/>
)
}
// Colon format: "03:04:12:05"
<Countdown target={new Date('2026-12-31')} format="colon" />
// Long format: "3 days 4 hours 12 minutes 5 seconds"
<Countdown target={Date.now() + 3_600_000} format="long" />
Type
feature
Installation
npm install @molecule/app-countdown-solid @molecule/app-solid @molecule/app-ui @molecule/app-ui-solid solid-js
API
Interfaces
CountdownState
Snapshot of time remaining until a target date.
interface CountdownState {
/** Days remaining. */
days: number
/** Hours (0-23) within current day. */
hours: number
/** Minutes (0-59) within current hour. */
minutes: number
/** Seconds (0-59) within current minute. */
seconds: number
/** Total milliseconds remaining (negative if past). */
msRemaining: number
/** True once `target` is in the past. */
expired: boolean
}
CountdownProps
Props accepted by the Countdown component — React's prop names.
Node-valued props are Solid JSX values; as everywhere in Solid they may also arrive as an accessor of one.
interface CountdownProps {
/** Target date / ISO string / epoch ms. */
target: Date | string | number
/** Display format. Defaults to `'compact'`. */
format?: 'compact' | 'long' | 'colon'
/** Renderer override — receives the live state for full control. */
render?: (state: CountdownState) => JSX.Element
/** Optional rendered when the timer expires. */
expired?: JSX.Element | (() => JSX.Element)
/** Extra classes. */
className?: string
}
Functions
Countdown(props)
Live countdown display with three default formats:
'compact'—3d 4h 12m 5s(skips zero leading units)'long'—3 days 4 hours 12 minutes 5 seconds'colon'—03:04:12:05
Pass render for full control over markup. Once the target has passed and
an expired node was given, that node renders instead of the display.
function Countdown(props: CountdownProps): JSX.Element
props— Component props (seeCountdownProps).
Returns: The rendered countdown.
useCountdown(target, tickMs)
Live-updating countdown to a target date, React's useCountdown in Solid's
idiom: the target and interval may each be a plain value or an accessor, and
the primitive follows a changed source on the same mount — a component
re-rendering with a new target prop behaves as React's hook does.
function useCountdown(
target: Date | string | number | Accessor<Date | string | number>,
tickMs?: number | undefined | Accessor<number | undefined>,
): {
/** Days remaining. */
days: Accessor<number>
/** Hours (0-23) within current day. */
hours: Accessor<number>
/** Minutes (0-59) within current hour. */
minutes: Accessor<number>
/** Seconds (0-59) within current minute. */
seconds: Accessor<number>
/** Total milliseconds remaining (negative if past). */
msRemaining: Accessor<number>
/** True once the target is in the past. */
expired: Accessor<boolean>
}
target— Date / ISO string / epoch ms.tickMs— Refresh interval. Defaults to1000;0or less disables it.
Returns: An accessor per live countdown field.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-solid^3.5.0 || ^4.0.0@molecule/app-ui^1.0.1@molecule/app-ui-solid^1.1.0solid-js^1.8.0
Runtime Dependencies
@molecule/app-solid@molecule/app-ui@molecule/app-ui-solidsolid-js
The built-in 'compact' and 'long' formats hardcode English unit labels
and pluralization ("3d 4h", "3 days 4 hours") — there is no locale bond.
For localized apps use the render prop with the useCountdown state and
compose translated units via t() (or Intl.RelativeTimeFormat). expired
only swaps the rendering once the target passes — schedule side effects
(redirects, refetches) from useCountdown().expired in an effect, not from
the component.