StealThis .dev

Scroll-Linked Number Counters

Numeric metrics animate from 0 to target as you scroll. Counter speed is directly linked to scroll position using GSAP ScrollTrigger scrub.

Open in Lab
gsapscrolltriggertextpluginlenis
Targets: JS HTML

Code

:root {
  --bg: #070a12;
  --text: #f0f4fb;
  --panel: #121a2b;
  --border: #263249;
  --accent: #86e8ff;
  --muted: #8a95a8;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Hero Section */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(135deg, rgba(134, 232, 255, 0.05) 0%, rgba(174, 82, 255, 0.05) 100%);
}

.hero .content {
  max-width: 600px;
  text-align: center;
}

.eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 1.5rem;
  letter-spacing: -1px;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 500px;
  margin: 0 auto;
}

/* Metrics Section */
.metrics-section {
  padding: 6rem 2rem;
  background: rgba(134, 232, 255, 0.02);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.metrics-grid {
  max-width: 1000px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2rem;
}

.metric-card {
  padding: 2.5rem 2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
  transition: all 0.3s ease;
}

.metric-card:hover {
  background: rgba(134, 232, 255, 0.08);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.metric-card.scrolling {
  background: rgba(134, 232, 255, 0.12);
  border-color: var(--accent);
}

.metric-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 0.5rem;
  display: inline;
}

.metric-unit {
  font-size: 1rem;
  color: var(--muted);
  margin-left: 0.25rem;
}

.metric-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.metric-subtext {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Details Section */
.details-section {
  max-width: 800px;
  margin: 4rem auto;
  padding: 4rem 2rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(18, 26, 43, 0.8);
}

.content {
  max-width: 800px;
  margin: 0 auto;
}

.details-section h2,
.final-section h2 {
  font-size: 1.8rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.details-section h3 {
  font-size: 1.2rem;
  margin-top: 1.5rem;
  margin-bottom: 0.8rem;
  color: var(--accent);
}

.details-section p,
.final-section p {
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
  line-height: 1.8;
}

code {
  background: rgba(134, 232, 255, 0.1);
  color: var(--accent);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.9rem;
}

.details-section ul,
.final-section ol {
  margin-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.details-section li,
.final-section li {
  color: var(--muted);
  margin-bottom: 0.8rem;
  line-height: 1.7;
}

.details-section li strong {
  color: var(--accent);
}

/* Final Section */
.final-section {
  max-width: 800px;
  margin: 0 auto;
  padding: 4rem 2rem;
}

/* Button */
.btn-back {
  display: inline-block;
  margin-top: 2rem;
  padding: 0.8rem 1.5rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-back:hover {
  background: rgba(134, 232, 255, 0.8);
  transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 2.5rem;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .metric-card {
    padding: 1.5rem 1rem;
  }

  .metric-value {
    font-size: 2rem;
  }

  .details-section {
    margin: 2rem auto;
    padding: 2rem 1.5rem;
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .metric-value {
    font-size: 1.8rem;
  }
}

html.reduced-motion .metric-card,
html.reduced-motion .hero,
html.reduced-motion .details-section,
html.reduced-motion .final-section {
  animation: none !important;
}

html.reduced-motion * {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

Scroll-Linked Number Counters

Numeric metrics animate from 0 to target as you scroll. Counter speed is directly linked to scroll position using GSAP ScrollTrigger scrub.

Source

  • Repository: libs-genclaude
  • Original demo id: 36-scroll-linked-counters

Notes

Numeric metrics animate from 0 to target as you scroll. Counter speed is directly linked to scroll position using GSAP ScrollTrigger scrub.