Skip to content

Abbreviated Expand

A copy-paste stats & counters component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.

Stats & CountersHTMLCSSany framework

Copy into your project

HTML
<!-- Abbreviated Expand — hover or keyboard-focus swaps the short form for the full count -->
<button type="button" class="nuda-sc2-abbrexpand"
        aria-label="1,204,893 total downloads, shown abbreviated as 1.2M, hover or focus to expand">
  <span class="nuda-sc2-abbrexpand__stack">
    <span class="nuda-sc2-abbrexpand__short">1.2M</span>
    <span class="nuda-sc2-abbrexpand__full">1,204,893</span>
  </span>
  <span class="nuda-sc2-abbrexpand__label">downloads</span>
</button>
CSS
.nuda-sc2-abbrexpand {
  all: unset;
  cursor: pointer;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
  animation: _nuda-sc2abbrexpand-in .6s cubic-bezier(.4,0,.2,1) backwards;
}

.nuda-sc2-abbrexpand:focus-visible {
  outline: 2px solid #e4ff54;
  outline-offset: 3px;
}

.nuda-sc2-abbrexpand__stack {
  position: relative;
  display: grid;
  height: 32px;
}

.nuda-sc2-abbrexpand__short,.nuda-sc2-abbrexpand__full {
  grid-area: 1/1;
  font: 800 24px ui-sans-serif,system-ui;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
  transition: opacity .3s ease,transform .3s ease;
}

.nuda-sc2-abbrexpand__short {
  opacity: 1;
  transform: translateY(0);
  color: #fafafa;
}

.nuda-sc2-abbrexpand__full {
  opacity: 0;
  transform: translateY(4px);
  color: #e4ff54;
}

.nuda-sc2-abbrexpand:hover .nuda-sc2-abbrexpand__short,.nuda-sc2-abbrexpand:focus-visible .nuda-sc2-abbrexpand__short {
  opacity: 0;
  transform: translateY(-4px);
}

.nuda-sc2-abbrexpand:hover .nuda-sc2-abbrexpand__full,.nuda-sc2-abbrexpand:focus-visible .nuda-sc2-abbrexpand__full {
  opacity: 1;
  transform: translateY(0);
}

.nuda-sc2-abbrexpand__label {
  font: 500 9px ui-sans-serif,system-ui;
  color: #777;
  text-transform: uppercase;
  letter-spacing: .08em;
}

@keyframes _nuda-sc2abbrexpand-in {
  from {
    opacity: 0;
    transform: scale(.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion:reduce) {
  .nuda-sc2-abbrexpand {
    animation: none !important;
    opacity: 1;
    transform: scale(1);
  }
  .nuda-sc2-abbrexpand__short,.nuda-sc2-abbrexpand__full {
    transition: none;
  }
}

How to use Abbreviated Expand

Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.

Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.

More stats & counters components

← Browse all NudaUI components