# Tally counter button

> A chrome hand tally counter: each press pushes the plunger and rolls the number wheels forward by one.

- Category: [Buttons](https://library.aimran.es/components/buttons)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-btn-tally
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

Hand tally counters are used to count people at doors and laps on a track, and this button copies the object closely: brushed chrome body, red plunger on top and four number wheels behind a dark window. Every click presses the plunger, rolls the wheels with a small overshoot, carries over from nine to zero and floats a +1 above. Use it for claps, votes, likes or attendance.

The main color tints the plunger and the floating +1, the secondary color sets the digits on the wheels. The number lives in the script, so you can start it from your own data, and screen readers hear the new total as part of the button name.

## Code

### HTML

```html
<button class="uvq01-tly" type="button"><span class="win" aria-hidden="true"><span class="wh"><span class="col" style="--d:0"><i>0</i><i>1</i><i>2</i><i>3</i><i>4</i><i>5</i><i>6</i><i>7</i><i>8</i><i>9</i><i>0</i></span></span><span class="wh"><span class="col" style="--d:1"><i>0</i><i>1</i><i>2</i><i>3</i><i>4</i><i>5</i><i>6</i><i>7</i><i>8</i><i>9</i><i>0</i></span></span><span class="wh"><span class="col" style="--d:2"><i>0</i><i>1</i><i>2</i><i>3</i><i>4</i><i>5</i><i>6</i><i>7</i><i>8</i><i>9</i><i>0</i></span></span><span class="wh"><span class="col" style="--d:7"><i>0</i><i>1</i><i>2</i><i>3</i><i>4</i><i>5</i><i>6</i><i>7</i><i>8</i><i>9</i><i>0</i></span></span></span><span class="t">Clap</span><span class="p1" aria-hidden="true">+1</span><span class="sr">127</span></button>
```

### CSS

```css
.uvq01-tly {
  --c1: #e4402f;
  --c2: #f3ead2;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq01-tly {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.005em;
  white-space: nowrap;
  user-select: none;
  gap: .9em;
  margin-top: .7em;
  padding: .55em 1.4em .55em .55em;
  border-radius: 1.2em;
  color: #24262a;
  background: linear-gradient(180deg,#f6f7f9,#cdd0d6 46%,#e9ebef 54%,#b9bdc4);
  box-shadow: inset 0 1px 0 #fff,inset 0 -1px 0 rgba(0,0,0,.2),0 0 0 1px #8d9199,0 12px 22px -12px rgba(0,0,0,.5);
  transition: transform calc(0.08s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-tly::before {
  content: "";
  position: absolute;
  right: 1.5em;
  top: -.62em;
  width: 1.7em;
  height: .7em;
  border-radius: .35em .35em 0 0;
  background: linear-gradient(90deg,color-mix(in srgb,var(--c1) 65%,#000),var(--c1) 45%,color-mix(in srgb,var(--c1) 72%,#000));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45),0 0 0 1px color-mix(in srgb,var(--c1) 45%,#000);
  transition: transform calc(0.08s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-tly .win {
  display: flex;
  gap: .1em;
  padding: .3em .35em;
  border-radius: .6em;
  background: #121316;
  box-shadow: inset 0 .15em .3em #000,0 1px 0 rgba(255,255,255,.75);
}

.uvq01-tly .wh {
  position: relative;
  width: .95em;
  height: 1.35em;
  overflow: hidden;
  border-radius: .15em;
  background: #26272b;
}

.uvq01-tly .wh::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,rgba(0,0,0,.75),transparent 32%,transparent 68%,rgba(0,0,0,.75));
  pointer-events: none;
}

.uvq01-tly .col {
  display: block;
  transform: translateY(calc(var(--d,0) * -1.35em));
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq01-tly .col i {
  display: block;
  height: 1.35em;
  font: 700 1em/1.35em ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
  font-style: normal;
  text-align: center;
  color: var(--c2);
}

.uvq01-tly .t {
  font-weight: 750;
}

.uvq01-tly .p1 {
  position: absolute;
  right: 3.6em;
  top: -.5em;
  font: 800 .8em/1 ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
  color: var(--c1);
  opacity: 0;
  pointer-events: none;
}

.uvq01-tly.is-bump .p1 {
  animation: uvq01-tly-p calc(0.7s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-tly .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.uvq01-tly:hover {
  background: linear-gradient(180deg,#fff,#d6d9de 46%,#f0f2f5 54%,#c2c6cc);
}

.uvq01-tly:active {
  transform: translateY(1px);
}

.uvq01-tly:active::before {
  transform: translateY(.32em);
}

.uvq01-tly:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

@keyframes uvq01-tly-p {
  0% {
    opacity: 0;
    transform: translateY(.4em);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-1.4em);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq01-tly,.uvq01-tly *,.uvq01-tly *::before,.uvq01-tly *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
```

### JavaScript

```js
document.querySelectorAll(".uvq01-tly").forEach(el => {
  const ws=[...el.querySelectorAll(".col")],sr=el.querySelector(".sr");let n=127;
const set=(v,anim)=>{const s=String(v).padStart(4,"0");ws.forEach((c,i)=>{const d=+s[i],cur=+(c.dataset.d||0);if(anim&&cur===9&&d===0){c.style.setProperty("--d",10);c.addEventListener("transitionend",()=>{if(c.dataset.d!=="0")return;c.style.transition="none";c.style.setProperty("--d",0);void c.offsetWidth;c.style.transition=""},{once:true})}else c.style.setProperty("--d",d);c.dataset.d=String(d)});sr.textContent=String(v)};
set(n,false);
el.addEventListener("click",()=>{n=(n+1)%10000;set(n,true);el.classList.remove("is-bump");void el.offsetWidth;el.classList.add("is-bump")})
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq01-tly {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.005em;
  white-space: nowrap;
  user-select: none;
  gap: .9em;
  margin-top: .7em;
  padding: .55em 1.4em .55em .55em;
  border-radius: 1.2em;
  color: #24262a;
  background: linear-gradient(180deg,#f6f7f9,#cdd0d6 46%,#e9ebef 54%,#b9bdc4);
  box-shadow: inset 0 1px 0 #fff,inset 0 -1px 0 rgba(0,0,0,.2),0 0 0 1px #8d9199,0 12px 22px -12px rgba(0,0,0,.5);
  transition: transform calc(0.08s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-tly::before {
  content: "";
  position: absolute;
  right: 1.5em;
  top: -.62em;
  width: 1.7em;
  height: .7em;
  border-radius: .35em .35em 0 0;
  background: linear-gradient(90deg,color-mix(in srgb,var(--c1) 65%,#000),var(--c1) 45%,color-mix(in srgb,var(--c1) 72%,#000));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45),0 0 0 1px color-mix(in srgb,var(--c1) 45%,#000);
  transition: transform calc(0.08s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-tly .win {
  display: flex;
  gap: .1em;
  padding: .3em .35em;
  border-radius: .6em;
  background: #121316;
  box-shadow: inset 0 .15em .3em #000,0 1px 0 rgba(255,255,255,.75);
}

.uvq01-tly .wh {
  position: relative;
  width: .95em;
  height: 1.35em;
  overflow: hidden;
  border-radius: .15em;
  background: #26272b;
}

.uvq01-tly .wh::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,rgba(0,0,0,.75),transparent 32%,transparent 68%,rgba(0,0,0,.75));
  pointer-events: none;
}

.uvq01-tly .col {
  display: block;
  transform: translateY(calc(var(--d,0) * -1.35em));
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq01-tly .col i {
  display: block;
  height: 1.35em;
  font: 700 1em/1.35em ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
  font-style: normal;
  text-align: center;
  color: var(--c2);
}

.uvq01-tly .t {
  font-weight: 750;
}

.uvq01-tly .p1 {
  position: absolute;
  right: 3.6em;
  top: -.5em;
  font: 800 .8em/1 ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
  color: var(--c1);
  opacity: 0;
  pointer-events: none;
}

.uvq01-tly.is-bump .p1 {
  animation: uvq01-tly-p calc(0.7s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-tly .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.uvq01-tly:hover {
  background: linear-gradient(180deg,#fff,#d6d9de 46%,#f0f2f5 54%,#c2c6cc);
}

.uvq01-tly:active {
  transform: translateY(1px);
}

.uvq01-tly:active::before {
  transform: translateY(.32em);
}

.uvq01-tly:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

@keyframes uvq01-tly-p {
  0% {
    opacity: 0;
    transform: translateY(.4em);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-1.4em);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq01-tly,.uvq01-tly *,.uvq01-tly *::before,.uvq01-tly *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const ws=[...el.querySelectorAll(".col")],sr=el.querySelector(".sr");let n=127;
const set=(v,anim)=>{const s=String(v).padStart(4,"0");ws.forEach((c,i)=>{const d=+s[i],cur=+(c.dataset.d||0);if(anim&&cur===9&&d===0){c.style.setProperty("--d",10);c.addEventListener("transitionend",()=>{if(c.dataset.d!=="0")return;c.style.transition="none";c.style.setProperty("--d",0);void c.offsetWidth;c.style.transition=""},{once:true})}else c.style.setProperty("--d",d);c.dataset.d=String(d)});sr.textContent=String(v)};
set(n,false);
el.addEventListener("click",()=>{n=(n+1)%10000;set(n,true);el.classList.remove("is-bump");void el.offsetWidth;el.classList.add("is-bump")})
}

export default function BtnTally() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#e4402f",
          "--c2": "#f3ead2",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <button className="uvq01-tly" type="button"><span className="win" aria-hidden="true"><span className="wh"><span className="col" style={{ "--d": "0" } as CSSProperties}><i>0</i><i>1</i><i>2</i><i>3</i><i>4</i><i>5</i><i>6</i><i>7</i><i>8</i><i>9</i><i>0</i></span></span><span className="wh"><span className="col" style={{ "--d": "1" } as CSSProperties}><i>0</i><i>1</i><i>2</i><i>3</i><i>4</i><i>5</i><i>6</i><i>7</i><i>8</i><i>9</i><i>0</i></span></span><span className="wh"><span className="col" style={{ "--d": "2" } as CSSProperties}><i>0</i><i>1</i><i>2</i><i>3</i><i>4</i><i>5</i><i>6</i><i>7</i><i>8</i><i>9</i><i>0</i></span></span><span className="wh"><span className="col" style={{ "--d": "7" } as CSSProperties}><i>0</i><i>1</i><i>2</i><i>3</i><i>4</i><i>5</i><i>6</i><i>7</i><i>8</i><i>9</i><i>0</i></span></span></span><span className="t">Clap</span><span className="p1" aria-hidden="true">+1</span><span className="sr">127</span></button>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Tally counter button” block (Buttons) from AIMRAN Library to my project.

## What it is
A chrome hand tally counter: each press pushes the plunger and rolls the number wheels forward by one.

## Chosen settings
- Main color: #e4402f
- Secondary color: #f3ead2
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Aplaudir"

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq01-tly {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.005em;
  white-space: nowrap;
  user-select: none;
  gap: .9em;
  margin-top: .7em;
  padding: .55em 1.4em .55em .55em;
  border-radius: 1.2em;
  color: #24262a;
  background: linear-gradient(180deg,#f6f7f9,#cdd0d6 46%,#e9ebef 54%,#b9bdc4);
  box-shadow: inset 0 1px 0 #fff,inset 0 -1px 0 rgba(0,0,0,.2),0 0 0 1px #8d9199,0 12px 22px -12px rgba(0,0,0,.5);
  transition: transform calc(0.08s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-tly::before {
  content: "";
  position: absolute;
  right: 1.5em;
  top: -.62em;
  width: 1.7em;
  height: .7em;
  border-radius: .35em .35em 0 0;
  background: linear-gradient(90deg,color-mix(in srgb,var(--c1) 65%,#000),var(--c1) 45%,color-mix(in srgb,var(--c1) 72%,#000));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45),0 0 0 1px color-mix(in srgb,var(--c1) 45%,#000);
  transition: transform calc(0.08s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-tly .win {
  display: flex;
  gap: .1em;
  padding: .3em .35em;
  border-radius: .6em;
  background: #121316;
  box-shadow: inset 0 .15em .3em #000,0 1px 0 rgba(255,255,255,.75);
}

.uvq01-tly .wh {
  position: relative;
  width: .95em;
  height: 1.35em;
  overflow: hidden;
  border-radius: .15em;
  background: #26272b;
}

.uvq01-tly .wh::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,rgba(0,0,0,.75),transparent 32%,transparent 68%,rgba(0,0,0,.75));
  pointer-events: none;
}

.uvq01-tly .col {
  display: block;
  transform: translateY(calc(var(--d,0) * -1.35em));
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq01-tly .col i {
  display: block;
  height: 1.35em;
  font: 700 1em/1.35em ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
  font-style: normal;
  text-align: center;
  color: var(--c2);
}

.uvq01-tly .t {
  font-weight: 750;
}

.uvq01-tly .p1 {
  position: absolute;
  right: 3.6em;
  top: -.5em;
  font: 800 .8em/1 ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
  color: var(--c1);
  opacity: 0;
  pointer-events: none;
}

.uvq01-tly.is-bump .p1 {
  animation: uvq01-tly-p calc(0.7s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-tly .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.uvq01-tly:hover {
  background: linear-gradient(180deg,#fff,#d6d9de 46%,#f0f2f5 54%,#c2c6cc);
}

.uvq01-tly:active {
  transform: translateY(1px);
}

.uvq01-tly:active::before {
  transform: translateY(.32em);
}

.uvq01-tly:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

@keyframes uvq01-tly-p {
  0% {
    opacity: 0;
    transform: translateY(.4em);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-1.4em);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq01-tly,.uvq01-tly *,.uvq01-tly *::before,.uvq01-tly *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const ws=[...el.querySelectorAll(".col")],sr=el.querySelector(".sr");let n=127;
const set=(v,anim)=>{const s=String(v).padStart(4,"0");ws.forEach((c,i)=>{const d=+s[i],cur=+(c.dataset.d||0);if(anim&&cur===9&&d===0){c.style.setProperty("--d",10);c.addEventListener("transitionend",()=>{if(c.dataset.d!=="0")return;c.style.transition="none";c.style.setProperty("--d",0);void c.offsetWidth;c.style.transition=""},{once:true})}else c.style.setProperty("--d",d);c.dataset.d=String(d)});sr.textContent=String(v)};
set(n,false);
el.addEventListener("click",()=>{n=(n+1)%10000;set(n,true);el.classList.remove("is-bump");void el.offsetWidth;el.classList.add("is-bump")})
}

export default function BtnTally() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#e4402f",
          "--c2": "#f3ead2",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <button className="uvq01-tly" type="button"><span className="win" aria-hidden="true"><span className="wh"><span className="col" style={{ "--d": "0" } as CSSProperties}><i>0</i><i>1</i><i>2</i><i>3</i><i>4</i><i>5</i><i>6</i><i>7</i><i>8</i><i>9</i><i>0</i></span></span><span className="wh"><span className="col" style={{ "--d": "1" } as CSSProperties}><i>0</i><i>1</i><i>2</i><i>3</i><i>4</i><i>5</i><i>6</i><i>7</i><i>8</i><i>9</i><i>0</i></span></span><span className="wh"><span className="col" style={{ "--d": "2" } as CSSProperties}><i>0</i><i>1</i><i>2</i><i>3</i><i>4</i><i>5</i><i>6</i><i>7</i><i>8</i><i>9</i><i>0</i></span></span><span className="wh"><span className="col" style={{ "--d": "7" } as CSSProperties}><i>0</i><i>1</i><i>2</i><i>3</i><i>4</i><i>5</i><i>6</i><i>7</i><i>8</i><i>9</i><i>0</i></span></span></span><span className="t">Clap</span><span className="p1" aria-hidden="true">+1</span><span className="sr">127</span></button>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
