Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="app"></div>
              
            
!

CSS

              
                @font-face {
  font-family: "Geist Sans";
  src: url("https://assets.codepen.io/605876/GeistVF.ttf") format("truetype");
}

*,
*:after,
*:before {
	box-sizing: border-box;
	transform-style: preserve-3d;
}

:root {
	--line: hsl(0 0% 95% / 0.25);
	--basic: ease;
	--back: 
    linear( 0, -0.0077 5.2%, -0.0452 16.98%, -0.0493 22.35%, -0.0418 25.57%,
       -0.0258 28.57%, -0.0007 31.42%, 0.0335 34.15%, 0.1242 39.03%, 0.2505 43.65%,
       0.3844 47.35%, 0.656 53.68%, 0.81 58.37%, 0.9282 63.52%, 0.9719 66.23%,
       1.0055 69.04%, 1.0255 71.4%, 1.0396 73.87%, 1.0477 76.48%, 1.05 79.27%,
       1.0419 84.36%, 1.0059 95.49%, 1 );
	--expo: 
    linear( 0, 0.0053 17.18%, 0.0195 26.59%, 0.0326 30.31%, 0.0506 33.48%,
       0.0744 36.25%, 0.1046 38.71%, 0.1798 42.62%, 0.2846 45.93%, 0.3991 48.37%,
       0.6358 52.29%, 0.765 55.45%, 0.8622 59.3%, 0.8986 61.51%, 0.9279 63.97%,
       0.9481 66.34%, 0.9641 69.01%, 0.9856 75.57%, 0.9957 84.37%, 1 );
	--sine: 
    linear( 0, 0.007 5.35%, 0.0282 10.75%, 0.0638 16.26%, 0.1144 21.96%,
       0.1833 28.16%, 0.2717 34.9%, 0.6868 62.19%, 0.775 68.54%, 0.8457 74.3%,
       0.9141 81.07%, 0.9621 87.52%, 0.9905 93.8%, 1 );
	--power: 
    linear( 0, 0.0012 14.95%, 0.0089 22.36%, 0.0297 28.43%, 0.0668 33.43%,
       0.0979 36.08%, 0.1363 38.55%, 0.2373 43.07%, 0.3675 47.01%, 0.5984 52.15%,
       0.7121 55.23%, 0.8192 59.21%, 0.898 63.62%, 0.9297 66.23%, 0.9546 69.06%,
       0.9733 72.17%, 0.9864 75.67%, 0.9982 83.73%, 1 );
	--circ: 
    linear( -0, 0.0033 5.75%, 0.0132 11.43%, 0.0296 16.95%, 0.0522 22.25%,
       0.0808 27.25%, 0.1149 31.89%, 0.1542 36.11%, 0.1981 39.85%, 0.2779 44.79%,
       0.3654 48.15%, 0.4422 49.66%, 0.5807 50.66%, 0.6769 53.24%, 0.7253 55.37%,
       0.7714 58.01%, 0.8142 61.11%, 0.8536 64.65%, 0.9158 72.23%, 0.9619 80.87%,
       0.9904 90.25%, 1 );
	--bounce: 
    linear( 0, 0.0039, 0.0157, 0.0352, 0.0625 9.09%,
       0.1407, 0.25, 0.3908, 0.5625, 0.7654,
       1, 0.8907, 0.8125 45.45%, 0.7852, 0.7657,
       0.7539, 0.75, 0.7539, 0.7657, 0.7852,
       0.8125 63.64%, 0.8905, 1 72.73%, 0.9727, 0.9532,
       0.9414, 0.9375, 0.9414, 0.9531, 0.9726,
       1, 0.9883, 0.9844, 0.9883, 1 );
  --elastic: 
    linear( 0, 0.0009 8.51%, -0.0047 19.22%, 0.0016 22.39%, 0.023 27.81%,
       0.0237 30.08%, 0.0144 31.81%, -0.0051 33.48%, -0.1116 39.25%, -0.1181 40.59%,
       -0.1058 41.79%, -0.0455, 0.0701 45.34%, 0.9702 55.19%, 1.0696 56.97%,
       1.0987 57.88%, 1.1146 58.82%, 1.1181 59.83%, 1.1092 60.95%, 1.0057 66.48%,
       0.986 68.14%, 0.9765 69.84%, 0.9769 72.16%, 0.9984 77.61%, 1.0047 80.79%,
       0.9991 91.48%, 1 );
  --ease: var(--back);
}

body {
	display: grid;
	place-items: center;
	min-height: 100vh;
	font-family:  "Geist Sans", "SF Pro Text", "SF Pro Icons", "AOS Icons", "Helvetica Neue", Helvetica, Arial, sans-serif, system-ui;
	font-weight: 80;
	background: hsl(0 0% 8%);
  overflow: hidden;
}

body::before {
	content: "";
	height: 100vh;
	width: 100vw;
	position: fixed;
	background:
		linear-gradient(90deg, var(--line) 1px, transparent 1px 10vmin) 0 -5vmin / 10vmin 10vmin,
		linear-gradient(var(--line) 1px, transparent 1px 10vmin) 0 -5vmin / 10vmin 10vmin;
	mask: linear-gradient(-15deg, transparent 30%, white);
	top: 0;
	z-index: -1;
	transform: translate3d(0, 0, -100vmin);
}

#app {
	display: grid;
	place-items: center;
	gap: 4rem;
}

h2 {
	font-weight: 160;
	margin: 0;
  transform-style: flat;
}

[aria-hidden="true"] {
	user-select: none;
	pointer-events: none;
}

[type=range] {
	accent-color: var(--line);
}

.counter {
	padding: 1rem 2rem;
	border: 2px solid var(--line);
	background: hsl(0 0% 2%);
	border-radius: 12px;
/*	aspect-ratio: 4 / 3;*/
	display: grid;
	place-items: center;
}

fieldset .sr-only {
	position: absolute;
	font-size: var(--font-size);
	line-height: var(--line-height);
	z-index: 2;
	letter-spacing: 2px;
	font-variant: tabular-nums;
	color: transparent;
}

fieldset {
	--mask-size: 0.25;
	--font-size: clamp(2rem, 4vw + 1rem, 8rem);
	--line-height: calc(var(--font-size) * 1.5);
	padding: 0;
}

legend {
	color: hsl(20 80% 50%);
	border: 0;
	font-weight: 120;
	font-size: calc(var(--font-size) * 0.25);
}

fieldset {
	margin: 0;
	border: 0;
}

.character {
	display: grid;
	height: 1lh;
	line-height: var(--line-height);
	font-variant: tabular-nums;
	font-size: var(--font-size);
	overflow: hidden;
	mask: linear-gradient(transparent, white calc(1lh * var(--mask-size)) calc(100% - (1lh * var(--mask-size))), transparent);
  transform-style: flat;
}

.character__track span {
	height: 1lh;
	font-weight: 120;
  transform-style: flat;
}

.character,
.character__track span {
	background: linear-gradient(hsl(0 0% 98%) 50%, hsl(0 0% 45%));
	background-attachment: fixed;
	background-clip: text;
	color: transparent;
  transform-style: flat;
}

.character {
	font-weight: 20;
}

.character__track {
	display: grid;
	translate: 0 calc((var(--v) + 1) * (var(--line-height) * -1));
	transition: translate calc(var(--transition) * 1s) var(--ease);
}

.character:first-of-type {
	margin-right: 0.2ch;
	opacity: 0.75;
	font-size: calc(var(--font-size) * 0.8);
}

.characters {
	display: flex;
	gap: 2px;
  transform-style: flat;
}

.fraction {
	font-size: calc(var(--font-size) * 0.75);
	opacity: 0.75;
	font-weight: 40;
	height: var(--line-height);
}

.fraction .character__track span {
	display: flex;
  flex-direction: column;
  align-items: end;
  padding: calc((var(--line-height) - var(--font-size)) * 0.2) 0;
}

.counter:last-of-type {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.counter:last-of-type [data-value] {
	position: relative;
}
.counter:last-of-type [data-value]::after {
	content: attr(data-value);
	position: absolute;
	bottom: 0%;
	left: 0%;
	font-family: "Geist Sans", sans-serif;
	font-weight: 120;

	background: linear-gradient(hsl(0 0% 98%) 50%, hsl(0 0% 45%));
	background-attachment: fixed;
	background-clip: text;
	color: transparent;
}

.counter:last-of-type .fraction[data-value]::after {
	display: flex;
  flex-direction: column;
  align-items: end;
  padding: calc((var(--line-height) - var(--font-size)) * 0.2) 0;
  height: var(--line-height);
}

.dg.ac {
	z-index: 9999 !important;
	transform: translate3d(0, 0, 100vmin);
}

/* Transitions */
[data-explode] #app {
	transform: rotateX(-24deg) rotateY(-40deg);
}



.counter:first-of-type {
	transform: translate3d(0, 0, calc(var(--depth) * 1));
}

.counter:last-of-type {
	transform: translate3d(0, 0, calc(var(--depth) * -1));
}

[data-explode] .counter:last-of-type {
	opacity: 1;
}

[data-explode] #app {
	--depth: 100px;
	transition: transform 0.5s;
}

#app {
	--depth: 0;
	transition: transform 0.5s 3s;
}

[data-explode] .counter {
	transition: transform 0.5s 1s;
}

.counter {
	transition: transform 0.5s 2s;
}

[data-explode] .counter:last-of-type {
	transition: transform 0.5s 1s ease, opacity 0.5s 1s steps(1, start), background 0.5s 2s, border-color 0.5s 2s;
}

.counter:last-of-type {
	transition: transform 0.5s 2s ease, opacity 0.5s 2s steps(1, end), background 0.5s 1s, border-color 0.5s 1s;
}

.counter:last-of-type .character {
	mask: unset;
	overflow: visible;
}

.counter:last-of-type .character__track span {
	opacity: 0;
}

[data-explode] .counter:last-of-type .character--symbol,
[data-explode] .counter:last-of-type .character__track span {
	transition: opacity 0.5s 3s;
	opacity: 0.5;
}
[data-explode] .counter:last-of-type [data-value]::after {
	transition: opacity 0.5s 3s;
	opacity: 0;
}

.counter:last-of-type .character--symbol,
.counter:last-of-type .character__track span {
	transition: opacity 0.5s;
}
.counter:last-of-type [data-value]::after {
	transition: opacity 0.5s;
}
.counter:last-of-type legend {
	transition: color 0.5s 1s;
}

[data-explode] .counter:last-of-type {
	background: hsl(0 0% 0% / 0.15);
	border-color: hsl(0 0% 95% / 0.15);
}

[data-explode] .counter:last-of-type legend {
	transition: color 0.5s 2s;
	color: hsl(0 0% 100% / 0.25);
}


              
            
!

JS

              
                import { GUI } from 'https://cdn.skypack.dev/dat.gui'
import React from 'https://cdn.skypack.dev/react'
import { render } from 'https://cdn.skypack.dev/react-dom'

const ROOT_NODE = document.querySelector('#app')

const CONFIG = {
  min: 0,
  max: 20000,
  step: 0.01,
  value: 12010.0,
  pad: true,
  explode: false,
  ease: 'elastic.inOut',
  transition: 2,
  currency: 'USD',
  ease: 'elastic',
  easeOptions: [
    'back',
    'basic',
    'bounce',
    'circ',
    'elastic',
    'expo',
    'power',
    'sine',
  ],
  currencyOptions: ['USD', 'GBP', 'EUR'],
}

const FORMATTERS = {
  USD: new Intl.NumberFormat('en-US', {
    style: 'currency',
    currency: 'USD',
  }),
  GBP: new Intl.NumberFormat('en-US', {
    style: 'currency',
    currency: 'GBP',
  }),
  EUR: new Intl.NumberFormat('en-US', {
    style: 'currency',
    currency: 'EUR',
  }),
  YEN: new Intl.NumberFormat('en-US', {
    style: 'currency',
    currency: 'YEN',
  }),
}

const Character = ({ className, key, value }) => {
  return (
    <span data-value={value} className={`character ${className || ''}`}>
      <span className="character__track" style={{ '--v': value }}>
        <span>9</span>
        {[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((val, index) => {
          return <span key={`${key}--${index}`}>{val}</span>
        })}
        <span>0</span>
      </span>
    </span>
  )
}

const Counter = ({ currency, pad, value }) => {
  const padCount = pad
    ? CONFIG.max.toFixed(2).toString().length - value.toString().length
    : 0

  const paddedValue = value
    .toString()
    .padStart(value.toString().length + padCount, '1')

  let i = 0
  const renderValue = FORMATTERS[currency]
    .format(paddedValue)
    .split('')
    .map((character, index) => {
      if (!isNaN(parseInt(character, 10)) && i < padCount) {
        i++
        return '0'
      }
      return character
    })
    .join('')

  return (
    <div className="counter">
      <fieldset>
        <legend>MRR</legend>
        <h2>
          <span className="sr-only">{renderValue}</span>
          <span aria-hidden="true" className="characters">
            {renderValue.split('').map((character, index) => {
              if (isNaN(parseInt(character, 10)))
                return (
                  <span key={index} className="character character--symbol">
                    {character}
                  </span>
                )
              return (
                <Character
                  key={index}
                  value={character}
                  className={
                    index > renderValue.split('').length - 3 ? 'fraction' : ''
                  }
                />
              )
            })}
          </span>
        </h2>
      </fieldset>
    </div>
  )
}

const App = () => {
  const [value, setValue] = React.useState(CONFIG.value.toFixed(2))
  // Create state and refs for the controller
  const [max, setMax] = React.useState(CONFIG.max)
  const [min, setMin] = React.useState(CONFIG.min)
  const [step, setStep] = React.useState(CONFIG.step)
  const [pad, setPad] = React.useState(CONFIG.pad)
  const [currency, setCurrency] = React.useState(CONFIG.currency)
  // const [pad, setPad] = React.useState(CONFIG.pad)
  const minController = React.useRef(null)
  const maxController = React.useRef(null)
  const stepController = React.useRef(null)
  const padController = React.useRef(null)
  const transitionController = React.useRef(null)
  const currencyController = React.useRef(null)
  const valueController = React.useRef(null)
  const easeController = React.useRef(null)
  React.useEffect(() => {
    const UPDATE = () => {
      minController.current.max(CONFIG.max - 1)
      maxController.current.min(CONFIG.min + 1)
      stepController.current.max(CONFIG.max)
      valueController.current.max(CONFIG.max)
      valueController.current.min(CONFIG.min)
      valueController.current.step(CONFIG.step)
      setMin(CONFIG.min)
      setMax(CONFIG.max)
      setStep(CONFIG.step)
      setPad(CONFIG.pad)
      setCurrency(CONFIG.currency)
      setValue(CONFIG.value.toFixed(2))
      document.documentElement.style.setProperty(
        '--transition',
        CONFIG.transition
      )
      document.documentElement.style.setProperty(
        '--ease',
        `var(--${CONFIG.ease})`
      )
    }
    // Set up the controller.
    const CTRL = new GUI({ width: 320 })
    const valueFolder = CTRL.addFolder('Config')
    minController.current = valueFolder.add(CONFIG, 'min', 0, CONFIG.max - 1, 1)
      .name('Min')
      .onChange(UPDATE)
    maxController.current = valueFolder.add(CONFIG, 'max', CONFIG.min + 1, 1000000, 1)
      .name('Max')
      .onChange(UPDATE)
    stepController.current = valueFolder.add(CONFIG, 'step', 0.01, CONFIG.max, 0.01)
      .name('Step')
      .onChange(UPDATE)
    padController.current = valueFolder.add(CONFIG, 'pad').name('Pad').onChange(UPDATE)
    currencyController.current = valueFolder.add(
      CONFIG,
      'currency',
      CONFIG.currencyOptions
    )
      .name('Currency')
      .onChange(UPDATE)
    transitionController.current = CTRL.add(CONFIG, 'transition', 0, 5, 0.05)
      .name('Transition (s)')
      .onChange(UPDATE)
    easeController.current = CTRL.add(CONFIG, 'ease', CONFIG.easeOptions)
      .name('Easing')
      .onChange(UPDATE)
    valueController.current = CTRL.add(
      CONFIG,
      'value',
      CONFIG.min,
      CONFIG.max,
      CONFIG.step
    )
      .name('Value')
      .onChange(UPDATE)
    CTRL.add(CONFIG, 'explode').name('Explode?').onChange(() => {
      document.documentElement.toggleAttribute('data-explode')
    })
    UPDATE()
  }, [])

  return (
    <>
      <Counter pad={pad} value={value} currency={currency} />
      <Counter pad={pad} value={value} currency={currency} />
    </>
  )
}

render(<App />, ROOT_NODE)

              
            
!
999px

Console