Countdowns

Countdowns display an anmiated countdown to a specific date.

Todo
We should consider allowing a specific date to be passed in as an argument so that the countdown can be more accurate.

Basic Countdown

A basic countdown accepts an ActiveSupport::Duration object as either the first positional argument or as the value of the :duration keyword argument.

Preview
s
Code
.flex.flex-col.gap-y-4.font-mono
  = daisy_countdown(60.seconds)
  = daisy_countdown(duration: 60.seconds, modifier: :letters)
Reset

Longer Countdown

If you want to display a countdown with multiple parts, you can build one using the ActiveSupport::Duration#build method.

Preview
:
:
-
-
h
m
s
hours
minutes
seconds
Code
.flex.flex-col.items-center.gap-y-4.font-mono
  = daisy_countdown(ActiveSupport::Duration.build(3725))
  = daisy_countdown(ActiveSupport::Duration.build(3725), separator: "-")
  = daisy_countdown(ActiveSupport::Duration.build(3725), modifier: :letters)
  = daisy_countdown(ActiveSupport::Duration.build(3725), modifier: :words)
Reset

Boxed Countdown

You can also display the countdowns in a box by customizing each part of the countdown.

Note that the wrapper text-sm class applies to the words ("hours", "minutes", and "seconds") and the global parts_css sets the size of the numbers.

You can also customize each part individually by using the days_css, hours_css, minutes_css, and seconds_css options.

And you can add custom HTML using either the global parts_html or the individual days_html, hours_html, minutes_html, and seconds_html options.

Preview
hours
minutes
seconds
Code
.flex.flex-col.items-center.gap-y-4.text-sm
  - box_css = "[:where(&)]:bg-neutral [:where(&)]:text-neutral-content rounded-box flex flex-col items-center p-2 [&_span]:font-mono [&_span]:text-5xl"
  = daisy_countdown(ActiveSupport::Duration.build(3725),
      modifier: :words,
      css: "gap-x-8",
      parts_css: box_css,
      seconds_css: "bg-red-600 text-white",
      seconds_html: { title: "You better hurry!" })
Reset
Made with by Profoundry .
Copyright © 2023-2025 Profoundry LLC.
All rights reserved.