Live Preview

Countdown

Instructions

Overview

Add a dynamic countdown timer to your website that displays the time remaining until a specific date and time.

Getting Started

Quick Start

  1. Click the Copy Component button on the top of the page.
  2. Paste the component into your Webstudio site.

Manual Start

  1. Add the Script: Copy and paste this code into your website's after the component:

[code-block]<script type="module" src="https://drevo.b-cdn.net/Library/Custom%20Components/Countdown/countdown-v1.0.js"></script>[/code-block]

  1. Add the Countdown Element: Place a container with the following attributes: <div dv-countdown dv-countdown-target-date="2024-12-31" dv-countdown-target-time="23:59:59" dv-countdown-timezone="+00:00"></div>. Inside this container, add an element with dv-countdown-display="true" to contain all countdown units: <div dv-countdown-display="true"><!-- Units go here --></div>

countdown attributes

Customization Options

Required Attributes

  • dv-countdown = Main attribute to identify the countdown component
  • dv-countdown-target-date = Target date in YYYY-MM-DD format
  • dv-countdown-target-time = Target time in HH:MM:SS format
  • dv-countdown-timezone = Timezone offset in +/-HH:MM format

Display Units

Add elements with the dv-countdown-unit attribute to display specific time units:

  • dv-countdown-unit="years" = Years remaining
  • dv-countdown-unit="months" = Months remaining
  • dv-countdown-unit="days" = Days remaining
  • dv-countdown-unit="hours" = Hours remaining
  • dv-countdown-unit="minutes" = Minutes remaining
  • dv-countdown-unit="seconds" = Seconds remaining

Example: <span dv-countdown-unit="days">00</span>

Completion Message

Add an element with dv-countdown-complete="true" to display when countdown reaches zero: <div dv-countdown-complete="true" style="display: none;">Countdown complete!</div>

Notes

  • The countdown updates automatically every second
  • When the countdown reaches zero, the display element is hidden and the complete element is shown
  • You can include any combination of time units
  • Time calculations adjust based on which units are displayed
  • The component automatically reinitializes when added to the DOM dynamically