Count

Make numbers count up or down on your site using native Webflow interactions.

Built for Webflow

Snippet

Copy the <script> and paste it in the <head> tag or before </body>

<!-- Snippets by The Lazy God • Count -->
<script defer src="https://cdn.jsdelivr.net/gh/the-lazy-god/[email protected]/tlg-count.min.js"></script>

Required setup

  1. Add the attribute to the text elements or spans
  2. Create CSS variables for each unique number
  3. Create your native Webflow interaction

1 Add the attribute to text element(s)

Add the attribute below to any element or <span> which has the number you want to count up or down.

Add the tlg-count attribute to the element with the number.
Attribute
Name
tlg-count
Copy
Value
number-1
And number-2, number-3 and so on...
Copy

2 Create a variable for each number

Create a variable of type size for each unique number. This will be used in the interaction to change the update the displayed number.

Create variables for each unique number.
Variable (type = size)
Name
tlg/count-1
Repeat tlg/count-2, tlg/count-3 as needed
Copy
Value
0px
Initialize this value to 0px

3 Create native Webflow interactions

Create any Webflow interaction where you animate the variables you created above. The value of the variable will correspond to the number shown ignoring the unit.

Create interactions to update the tlg/count-1 variables.

Optional add-ons

  • Number of decimals
  • Decimal separator
  • Thousand separator
  • Minimum number of digits

Number of decimals

Add this attribute to the tlg-count element to set a custom number of decimals to your numbers.

Default is 0 decimals.

Attribute
Optional
Name
tlg-count-decimals
Copy
Value
{number}
Default = 0

Set decimal separator

Add this attribute to the tlg-count element to set a custom decimal separator.

Default is '.' as a decimal separator.

Attribute
Optional
Name
tlg-count-decimal-separator
Copy
Value
{character or space}
Default = "."

Set thousand separator

Add this attribute to the tlg-count element to set a custom thousand separator.

By default there is no thousand separator.

Attribute
Optional
Name
tlg-count-thousand-separator
Copy
Value
{character or space}
Default = none

Minimum number of digits

Add this attribute to the tlg-count element to set a the minimum number of digits. Applying this will add leading zeroes to a number e.g. with tlg-count-digits="3" the number "7" will show as "007".

Especially great with monospaced fonts.

Attribute
Optional
Name
tlg-count-digits
Copy
Value
{number}

Example

In the box below is a mouse movement interaction as well as a click interaction on each of the buttons.

12.34x 12.34y
9,001