Countdown
Display time remaining with various styles and animations
Class Reference Basic
Control the displayed value by updating the '--value' CSS variable with JS (range: 0-99) ex:
let countdownValue = 60;
const countdownElement = document.querySelector('.countdown span');
// Update every second
const interval = setInterval(() => {
countdownValue = Math.max(0, countdownValue - 1);
if (countdownValue === 0) {
countdownValue = 60; // Reset
}
countdownElement.style.setProperty('--value', countdownValue);
}, 1000);
Clock Style
Labeled
days
hours
min
sec
units = [(15, "days"), (10, "hours"), (24, "min"), (59, "sec")]
Div(
*(Div(
Span(
Span(
style=f"--value:{value};",
**{"data-countdown": "true"} if unit == "sec" else {}
),
cls='countdown font-mono text-4xl'
),
unit
) for value, unit in units),
cls='flex gap-5'
)
Auto-import documentation coming soon...
days
hours
min
sec
units = [(15, "days"), (10, "hours"), (24, "min"), (59, "sec")]
Div(
*(Div(
Span(
Span(
style=f"--value:{value};",
**{"data-countdown": "true"} if unit == "sec" else {}
),
cls='countdown font-mono text-5xl'
),
unit,
cls='flex flex-col'
) for value, unit in units),
cls='grid auto-cols-max grid-flow-col gap-5 text-center'
)
Auto-import documentation coming soon...
days
hours
min
sec
units = [(15, "days"), (10, "hours"), (24, "min"), (59, "sec")]
Div(
*(Div(
Span(
Span(
style=f"--value:{value};",
**{"data-countdown": "true"} if unit == "sec" else {}
),
cls='countdown font-mono text-5xl'
),
unit,
cls='bg-neutral rounded-box text-neutral-content flex flex-col p-2'
) for value, unit in units),
cls='grid auto-cols-max grid-flow-col gap-5 text-center'
)
Auto-import documentation coming soon...
Class Reference
Class | Type | Description |
---|---|---|
countdown | Component | Base countdown container |
Do you have a question? ask the community
Do you see a bug? open an issue on GitHub
LLMs Context: Full Markdown | This Component