npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

count-down-web-component

v1.2.0

Published

A progressively enhanced `<count-down>` custom element that counts down to a specified date.

Readme

Countdown web component

A progressively enhanced <count-down> custom element that counts down to a specified date.

Demo.

Installation

Self hosted

Add the following to an HTML document:

<script type="module" src="path/to/countdown.js"></script>

CDN

Add the following to an HTML document:

<script type="module" src="https://unpkg.com/[email protected]/lib/countdown.js"></script>

NPM

Run npm i count-down-web-component.

Usage

First create a <count-down> element with default content for users of browsers that don't support web components:

<count-down>
  <h2 slot="heading">Doors open in</h2>
  <time>2019-06-01</time>
</count-down>

If the text content of the <time> element isn't a valid string, a datetime attribute must be added containing a valid string as its value.

Then add attributes to control the end date of the countdown and its layout breakpoints.

<count-down ends="2019-06-01" breakpoint1="25em" breakpoint2="50em">
  <h2 slot="heading">Doors open in</h2>
  <time>2019-06-01</time>
</count-down>

Attributes

ends - The date, and optional time, the countdown will end at. Must be one of the following formats from https://html.spec.whatwg.org/multipage/text-level-semantics.html#datetime-value:

  • valid date string
  • valid local date and time string
  • valid global date and time string
  • Four or more ASCII digits, at least one of which is not U+0030 DIGIT ZERO (0)

breakpoint1 - The days, hours, minutes and seconds are displayed in a single column CSS grid. This attribute sets the min-width media query where it goes to two columns.

breakpoint2 - This attribute sets the min-width media query where the grid goes to four columns.

All attributes can be updated programatically, and the UI will update to reflect the changes.

const clock = document.querySelector('count-down');
clock.ends = '2022-05-10';
clock.breakpoint1 = '100rem';
clock.breakpoint2 = '800px';

Styling

The <count-down> element can be styled using a universal, element, class, id or attribute selector as normal. Inherited properties will also work inside its shadow DOM e.g. font-family and color.

Two custom properties are available to set the font-size of the numbers and their units:

--countdown-number-font-size

--countdown-unit-font-size

Don't forget styles for the default experience!

License

MIT License