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

digit-spinner

v0.1.0

Published

A lightweight web component for odometer-style digit spinners and simple numeric counters.

Downloads

12

Readme

Digit Spinner

A smooth, animated odometer-like web component built with Lit. Display numbers with beautiful spinning digit animations that transition seamlessly between values. See the documentation for more details and a live demo.

Features

  • 🎯 Smooth Animations: Fluid digit transitions with customizable easing
  • 🔄 Multi-Direction: Can animate up, down, or the shortest path
  • 🎨 Customizable Styling: CSS custom properties for complete visual control
  • 📱 Lightweight: Built with Lit for optimal performance
  • 🔢 Flexible Formatting: Support for leading zeros and minimum digit counts
  • 🎪 Rich Events: Detailed animation lifecycle events

Installation

npm install digit-spinner

Basic Usage

<script type="module" src="node_modules/digit-spinner/dist/index.js"></script>

<!-- Simple counter -->
<digit-spinner value="42"></digit-spinner>

API Reference

<digit-spinner>

The main component that displays animated numbers with spinning digit transitions.

Properties

| Property | Attribute | Type | Default | Description | | ----------- | ------------ | -------- | ---------------------------------- | --------------------------------------------------------- | | value | value | number | 0 | The numeric value to display | | direction | direction | string | 'forward' | Animation direction: 'forward', 'backward', or 'shortest' | | duration | duration | number | 200 | Animation duration in milliseconds | | easing | easing | string | 'cubic-bezier(0.83, 0, 0.17, 1)' | Animation easing function | | minDigits | min-digits | number | 0 | Minimum number of digits (pads with leading zeros) |

Methods

| Method | Parameters | Description | | ----------------- | ----------------- | ------------------------------------------ | | increment(num?) | num: number = 1 | Increase the value by the specified amount | | decrement(num?) | num: number = 1 | Decrease the value by the specified amount |

Events

The <digit-spinner> element emits the following events:

| Event | Properties | Description | | ------------------ | ----------------------------------------------- | --------------------------------------------- | | digit-flip-start | {from: number, to: number} | Fired when digit animation begins | | digit-flip-end | {from: number, to: number} | Fired when digit animation completes | | digit-wrap | {from: number, to: number, direction: string} | Fired when digit wraps from 9 to 0, or 0 to 9 |

Examples

<!-- Basic usage -->
<digit-spinner value="123"></digit-spinner>

<!-- With leading zeros -->
<digit-spinner value="42" min-digits="4"></digit-spinner>
<!-- Shows: 0042 -->

<!-- Programmatic control -->
<digit-spinner id="counter" value="0" min-digits="3"></digit-spinner>
<button onclick="document.getElementById('counter').increment()">+</button>
<button onclick="document.getElementById('counter').decrement()">-</button>

Styling

Customize the appearance using CSS custom properties:

digit-spinner {
  --digit-font-size: 2rem;
  --digit-font: 'Courier New', monospace;
  --digit-color: #333;
  --digit-background-color: #f0f0f0;
}

CSS Parts

Internal elements can also be styled using CSS parts:

digit-spinner::part(container) {
  /* Style the main container */
}

digit-spinner::part(digit-wrapper) {
  /* Style individual digit wrappers */
}

digit-spinner::part(digit) {
  /* Style digit elements */
  border-radius: 4px;
  padding: 8px;
}

Advanced Examples

Event Handling

In this example, we listen for the digit-flip-start event to log the digit that has begun flipping.

<digit-spinner id="event-demo" value="10"></digit-spinner>

<script>
  document
    .getElementById('event-demo')
    .addEventListener('digit-flip-start', (e) => {
      const origin = e.composedPath()[0]; // Reference to the digit
      console.log(
        `Digit ${origin} has started flipping from ${e.from} to ${e.to}`
      );
    });
</script>

Custom Styled Odometer

<style>
  digit-spinner {
    --digit-font-size: 2rem;
    --digit-font: 'Courier New', monospace;
    --digit-color: #333;
    --digit-background-color: #f0f0f0;
  }
</style>

<digit-spinner value="88888"></digit-spinner>

Browser Support

This component uses modern web standards and requires:

  • ES2020+ support
  • Custom Elements v1
  • CSS Custom Properties
  • Web Animations API

Supports all modern browsers including Chrome 80+, Firefox 75+, Safari 13.1+, and Edge 80+.

Development

The component is built with:

  • Lit - Efficient web component library
  • @lit-labs/motion - Animation utilities
  • TypeScript - Type safety and better development experience

Credits

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.