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 class="controls">
  <label for="slow">Slow Down</label>
  <input id="slow" type="checkbox" />
  <label for="show">Show Sprite</label>
  <input id="show" type="checkbox" />
  <label for="zoom">Zoom Out</label>
  <input id="zoom" type="checkbox" />
  <label for="step">Step Ease</label>
  <input id="step" type="checkbox" checked="true" />
</div>
<button>
  <img aria-hidden="true" src="https://assets.codepen.io/605876/sprite.svg" />
  <span class="sr-only">Repost</span>
</button>
<div class="sprite-container">
  <svg viewBox="0 0 756 36" fill="none" xmlns="http://www.w3.org/2000/svg">
    <g>
      <path d="M10.5 9.88L14.932 14.02L13.568 15.48L11.5 13.55V22C11.5 23.1 12.396 24 13.5 24H19V26H13.5C11.291 26 9.5 24.21 9.5 22V13.55L7.432 15.48L6.068 14.02L10.5 9.88ZM22.5 12H17V10H22.5C24.709 10 26.5 11.79 26.5 14V22.45L28.568 20.52L29.932 21.98L25.5 26.12L21.068 21.98L22.432 20.52L24.5 22.45V14C24.5 12.9 23.604 12 22.5 12Z" fill="currentColor" />
    </g>
    <g>
      <path d="M50.7109 14.9122L48.7224 9.18263L42.8708 10.7767L43.396 12.7044L46.0443 11.9843C45.6983 12.5762 45.5 13.2649 45.5 14V22C45.5 24.2091 47.2909 26 49.5 26H53V24H49.5C48.3954 24 47.5 23.1046 47.5 22V14C47.5 13.5812 47.6287 13.1924 47.8488 12.8711L47.8946 12.8953L48.8233 15.5672L50.7109 14.9122Z" fill="currentColor" />
      <g>
        <path d="M57.2891 21.0878L59.2776 26.8174L65.1292 25.2233L64.604 23.2956L61.9557 24.0157C62.3017 23.4238 62.5 22.7351 62.5 22V14C62.5 11.7909 60.7091 10 58.5 10H55V12H58.5C59.6046 12 60.5 12.8954 60.5 14V22C60.5 22.4188 60.3713 22.8076 60.1512 23.1289L60.1054 23.1047L59.1767 20.4328L57.2891 21.0878Z" fill="currentColor" />
      </g>
    </g>
    <g>
      <path fill-rule="evenodd" clip-rule="evenodd" d="M85.7598 15.3836L87.4853 9.56944L81.802 7.45229L81.1047 9.32467L83.755 10.3133L83.7898 10.383C82.4362 11.0242 81.5 12.4028 81.5 14V22C81.5 24.2091 83.2909 26 85.5 26H87V24H85.5C84.3954 24 83.5 23.1046 83.5 22V14C83.5 13.212 83.9557 12.5305 84.6179 12.2045L83.8444 14.8151L85.7598 15.3836Z" fill="currentColor" />
      <path fill-rule="evenodd" clip-rule="evenodd" d="M94.2402 20.6164L92.5147 26.4306L98.198 28.5477L98.8953 26.6753L96.245 25.6867L96.2102 25.617C97.5638 24.9758 98.5 23.5972 98.5 22V14C98.5 11.7909 96.7091 10 94.5 10H93V12H94.5C95.6046 12 96.5 12.8954 96.5 14V22C96.5 22.788 96.0443 23.4695 95.3821 23.7955L96.1556 21.1849L94.2402 20.6164Z" fill="currentColor" />
    </g>
    <g>
      <path d="M121.98 15.432L126.12 11L121.98 6.568L120.52 7.932L122.45 10L121.5 10C119.291 10 117.5 11.7909 117.5 14V22C117.5 23.3127 118.132 24.4777 119.109 25.207L120.306 23.6048C119.817 23.2403 119.5 22.6571 119.5 22V14C119.5 12.8954 120.395 12 121.5 12L122.45 12L120.52 14.068L121.98 15.432Z" fill="currentColor" />
      <path d="M130.02 20.568L125.88 25L130.02 29.432L131.48 28.068L129.55 26L130.5 26C132.709 26 134.5 24.2091 134.5 22V14C134.5 12.6873 133.868 11.5223 132.891 10.793L131.694 12.3952C132.183 12.7597 132.5 13.3429 132.5 14V22C132.5 23.1046 131.605 24 130.5 24L129.55 24L131.48 21.932L130.02 20.568Z" fill="currentColor" />
    </g>
    <g>
      <path d="M161.98 15.432L166.12 11L161.98 6.568L160.52 7.932L162.45 10L157.5 10C155.291 10 153.5 11.7909 153.5 14V22H155.5V14C155.5 12.8954 156.395 12 157.5 12L162.45 12L160.52 14.068L161.98 15.432Z" fill="currentColor" />
      <path d="M162.02 20.568L157.88 25L162.02 29.432L163.48 28.068L161.55 26L166.5 26C168.709 26 170.5 24.2091 170.5 22V14H168.5V22C168.5 23.1046 167.605 24 166.5 24L161.55 24L163.48 21.932L162.02 20.568Z" fill="currentColor" />
    </g>
    <g>
      <path d="M202.48 15.432L206.62 11L202.48 6.568L201.02 7.932L202.95 10V10.025C202.802 10.0085 202.652 10 202.5 10H193.5C191.291 10 189.5 11.7909 189.5 14V19H191.5V14C191.5 12.8954 192.395 12 193.5 12H202.5C202.641 12 202.778 12.0145 202.911 12.0422L201.02 14.068L202.48 15.432Z" fill="currentColor" />
      <path d="M193.52 20.568L189.38 25L193.52 29.432L194.98 28.068L193.05 26V25.975C193.198 25.9915 193.348 26 193.5 26H202.5C204.709 26 206.5 24.2091 206.5 22V17H204.5V22C204.5 23.1046 203.605 24 202.5 24H193.5C193.359 24 193.222 23.9855 193.089 23.9578L194.98 21.932L193.52 20.568Z" fill="currentColor" />
    </g>
    <g>
      <path d="M237.378 15.0838L243.294 13.7465L242.362 7.75364L240.388 8.0607L240.801 10.7279C240.151 10.2693 239.357 10 238.5 10H229.5C227.291 10 225.5 11.7909 225.5 14V16H227.5V14C227.5 12.8954 228.395 12 229.5 12H238.5C238.972 12 239.405 12.1632 239.747 12.4361L239.697 12.5099L236.938 13.1349L237.378 15.0838Z" fill="currentColor" />
      <path d="M230.622 20.9162L224.706 22.2535L225.638 28.2464L227.612 27.9393L227.199 25.2721C227.849 25.7307 228.643 26 229.5 26H238.5C240.709 26 242.5 24.2091 242.5 22V20H240.5V22C240.5 23.1046 239.605 24 238.5 24H229.5C229.028 24 228.595 23.8368 228.253 23.5639L228.303 23.4901L231.062 22.8651L230.622 20.9162Z" fill="currentColor" />
    </g>
    <g>
      <path d="M273.072 14.0452L278.759 16.1524L281.249 10.622L279.427 9.80204L278.264 12.3809L278.175 12.4183C277.562 10.9958 276.147 10 274.5 10H265.5C263.662 10 262.114 11.2395 261.645 12.9282L263.605 13.3599C263.872 12.5692 264.619 12 265.5 12H274.5C275.283 12 275.961 12.4498 276.289 13.1051L273.767 12.1717L273.072 14.0452Z" fill="currentColor" />
      <path d="M266.928 21.9548L261.241 19.8476L258.751 25.378L260.573 26.198L261.736 23.6191L261.825 23.5817C262.438 25.0042 263.853 26 265.5 26H274.5C276.338 26 277.886 24.7605 278.355 23.0718L276.395 22.6401C276.128 23.4308 275.381 24 274.5 24H265.5C264.717 24 264.039 23.5502 263.711 22.8949L266.233 23.8283L266.928 21.9548Z" fill="currentColor" />
    </g>
    <g>
      <path d="M314.5 14.45V14C314.5 11.7909 312.709 10 310.5 10H301.5C301.331 10 301.164 10.0105 301 10.0309V12.063C301.16 12.0219 301.327 12 301.5 12H310.5C311.605 12 312.5 12.8954 312.5 14V14.45L310.432 12.52L309.068 13.98L313.5 18.12L317.932 13.98L316.568 12.52L314.5 14.45Z" fill="currentColor" />
      <path d="M297.5 21.55V22C297.5 24.2091 299.291 26 301.5 26H310.5C310.669 26 310.836 25.9895 311 25.9691V23.937C310.84 23.9781 310.673 24 310.5 24H301.5C300.395 24 299.5 23.1046 299.5 22V21.55L301.568 23.48L302.932 22.02L298.5 17.88L294.068 22.02L295.432 23.48L297.5 21.55Z" fill="currentColor" />
    </g>
    <g>
      <path d="M339 12V10H346.5C348.709 10 350.5 11.7909 350.5 14V17.45L352.568 15.52L353.932 16.98L349.5 21.12L345.068 16.98L346.432 15.52L348.5 17.45V14C348.5 12.8954 347.605 12 346.5 12H339Z" fill="currentColor" />
      <path d="M345 24V26H337.5C335.291 26 333.5 24.2091 333.5 22V18.55L331.432 20.48L330.068 19.02L334.5 14.88L338.932 19.02L337.568 20.48L335.5 18.55V22C335.5 23.1046 336.395 24 337.5 24H345Z" fill="currentColor" />
    </g>
    <g>
      <path d="M386.475 22.45C386.492 22.3023 386.5 22.1521 386.5 22V14C386.5 11.7909 384.709 10 382.5 10H377V12H382.5C383.605 12 384.5 12.8954 384.5 14V22C384.5 22.1407 384.485 22.2781 384.458 22.4106L382.432 20.52L381.068 21.98L385.5 26.12L389.932 21.98L388.568 20.52L386.5 22.45H386.475Z" fill="currentColor" />
      <path d="M369.525 13.55C369.508 13.6977 369.5 13.8479 369.5 14V22C369.5 24.2091 371.291 26 373.5 26H379V24H373.5C372.395 24 371.5 23.1046 371.5 22V14C371.5 13.8593 371.515 13.7219 371.542 13.5894L373.568 15.48L374.932 14.02L370.5 9.88L366.068 14.02L367.432 15.48L369.5 13.55H369.525Z" fill="currentColor" />
    </g>
    <g>
      <path d="M410.711 14.9122L408.722 9.18263L402.871 10.7767L403.396 12.7044L406.044 11.9843C405.698 12.5762 405.5 13.2649 405.5 14V22C405.5 24.2091 407.291 26 409.5 26H413V24H409.5C408.395 24 407.5 23.1046 407.5 22V14C407.5 13.5812 407.629 13.1924 407.849 12.8711L407.895 12.8953L408.823 15.5672L410.711 14.9122Z" fill="currentColor" />
      <g>
        <path d="M417.289 21.0878L419.278 26.8174L425.129 25.2233L424.604 23.2956L421.956 24.0157C422.302 23.4238 422.5 22.7351 422.5 22V14C422.5 11.7909 420.709 10 418.5 10H415V12H418.5C419.605 12 420.5 12.8954 420.5 14V22C420.5 22.4188 420.371 22.8076 420.151 23.1289L420.105 23.1047L419.177 20.4328L417.289 21.0878Z" fill="currentColor" />
      </g>
    </g>
    <g>
      <path fill-rule="evenodd" clip-rule="evenodd" d="M445.76 15.3836L447.485 9.56944L441.802 7.45229L441.105 9.32467L443.755 10.3133L443.79 10.383C442.436 11.0242 441.5 12.4028 441.5 14V22C441.5 24.2091 443.291 26 445.5 26H447V24H445.5C444.395 24 443.5 23.1046 443.5 22V14C443.5 13.212 443.956 12.5305 444.618 12.2045L443.844 14.8151L445.76 15.3836Z" fill="currentColor" />
      <path fill-rule="evenodd" clip-rule="evenodd" d="M454.24 20.6164L452.515 26.4306L458.198 28.5477L458.895 26.6753L456.245 25.6867L456.21 25.617C457.564 24.9758 458.5 23.5972 458.5 22V14C458.5 11.7909 456.709 10 454.5 10H453V12H454.5C455.605 12 456.5 12.8954 456.5 14V22C456.5 22.788 456.044 23.4695 455.382 23.7955L456.156 21.1849L454.24 20.6164Z" fill="currentColor" />
    </g>
    <g>
      <path d="M481.98 15.432L486.12 11L481.98 6.568L480.52 7.932L482.45 10L481.5 10C479.291 10 477.5 11.7909 477.5 14V22C477.5 23.3127 478.132 24.4777 479.109 25.207L480.306 23.6048C479.817 23.2403 479.5 22.6571 479.5 22V14C479.5 12.8954 480.395 12 481.5 12L482.45 12L480.52 14.068L481.98 15.432Z" fill="currentColor" />
      <path d="M490.02 20.568L485.88 25L490.02 29.432L491.48 28.068L489.55 26L490.5 26C492.709 26 494.5 24.2091 494.5 22V14C494.5 12.6873 493.868 11.5223 492.891 10.793L491.694 12.3952C492.183 12.7597 492.5 13.3429 492.5 14V22C492.5 23.1046 491.605 24 490.5 24L489.55 24L491.48 21.932L490.02 20.568Z" fill="currentColor" />
    </g>
    <g>
      <path d="M521.98 15.432L526.12 11L521.98 6.568L520.52 7.932L522.45 10L517.5 10C515.291 10 513.5 11.7909 513.5 14V22H515.5V14C515.5 12.8954 516.395 12 517.5 12L522.45 12L520.52 14.068L521.98 15.432Z" fill="currentColor" />
      <path d="M522.02 20.568L517.88 25L522.02 29.432L523.48 28.068L521.55 26L526.5 26C528.709 26 530.5 24.2091 530.5 22V14H528.5V22C528.5 23.1046 527.605 24 526.5 24L521.55 24L523.48 21.932L522.02 20.568Z" fill="currentColor" />
    </g>
    <g>
      <path d="M562.48 15.432L566.62 11L562.48 6.568L561.02 7.932L562.95 10V10.025C562.802 10.0085 562.652 10 562.5 10H553.5C551.291 10 549.5 11.7909 549.5 14V19H551.5V14C551.5 12.8954 552.395 12 553.5 12H562.5C562.641 12 562.778 12.0145 562.911 12.0422L561.02 14.068L562.48 15.432Z" fill="currentColor" />
      <path d="M553.52 20.568L549.38 25L553.52 29.432L554.98 28.068L553.05 26V25.975C553.198 25.9915 553.348 26 553.5 26H562.5C564.709 26 566.5 24.2091 566.5 22V17H564.5V22C564.5 23.1046 563.605 24 562.5 24H553.5C553.359 24 553.222 23.9855 553.089 23.9578L554.98 21.932L553.52 20.568Z" fill="currentColor" />
    </g>
    <g>
      <path d="M597.378 15.0838L603.294 13.7465L602.362 7.75364L600.388 8.0607L600.801 10.7279C600.151 10.2693 599.357 10 598.5 10H589.5C587.291 10 585.5 11.7909 585.5 14V16H587.5V14C587.5 12.8954 588.395 12 589.5 12H598.5C598.972 12 599.405 12.1632 599.747 12.4361L599.697 12.5099L596.938 13.1349L597.378 15.0838Z" fill="currentColor" />
      <path d="M590.622 20.9162L584.706 22.2535L585.638 28.2464L587.612 27.9393L587.199 25.2721C587.849 25.7307 588.643 26 589.5 26H598.5C600.709 26 602.5 24.2091 602.5 22V20H600.5V22C600.5 23.1046 599.605 24 598.5 24H589.5C589.028 24 588.595 23.8368 588.253 23.5639L588.303 23.4901L591.062 22.8651L590.622 20.9162Z" fill="currentColor" />
    </g>
    <g>
      <path d="M633.072 14.0452L638.759 16.1524L641.249 10.622L639.427 9.80204L638.264 12.3809L638.175 12.4183C637.562 10.9958 636.147 10 634.5 10H625.5C623.662 10 622.114 11.2395 621.645 12.9282L623.605 13.3599C623.872 12.5692 624.619 12 625.5 12H634.5C635.283 12 635.961 12.4498 636.289 13.1051L633.767 12.1717L633.072 14.0452Z" fill="currentColor" />
      <path d="M626.928 21.9548L621.241 19.8476L618.751 25.378L620.573 26.198L621.736 23.6191L621.825 23.5817C622.438 25.0042 623.853 26 625.5 26H634.5C636.338 26 637.886 24.7605 638.355 23.0718L636.395 22.6401C636.128 23.4308 635.381 24 634.5 24H625.5C624.717 24 624.039 23.5502 623.711 22.8949L626.233 23.8283L626.928 21.9548Z" fill="currentColor" />
    </g>
    <g>
      <path d="M674.5 14.45V14C674.5 11.7909 672.709 10 670.5 10H661.5C661.331 10 661.164 10.0105 661 10.0309V12.063C661.16 12.0219 661.327 12 661.5 12H670.5C671.605 12 672.5 12.8954 672.5 14V14.45L670.432 12.52L669.068 13.98L673.5 18.12L677.932 13.98L676.568 12.52L674.5 14.45Z" fill="currentColor" />
      <path d="M657.5 21.55V22C657.5 24.2091 659.291 26 661.5 26H670.5C670.669 26 670.836 25.9895 671 25.9691V23.937C670.84 23.9781 670.673 24 670.5 24H661.5C660.395 24 659.5 23.1046 659.5 22V21.55L661.568 23.48L662.932 22.02L658.5 17.88L654.068 22.02L655.432 23.48L657.5 21.55Z" fill="currentColor" />
    </g>
    <g>
      <path d="M699 12V10H706.5C708.709 10 710.5 11.7909 710.5 14V17.45L712.568 15.52L713.932 16.98L709.5 21.12L705.068 16.98L706.432 15.52L708.5 17.45V14C708.5 12.8954 707.605 12 706.5 12H699Z" fill="currentColor" />
      <path d="M705 24V26H697.5C695.291 26 693.5 24.2091 693.5 22V18.55L691.432 20.48L690.068 19.02L694.5 14.88L698.932 19.02L697.568 20.48L695.5 18.55V22C695.5 23.1046 696.395 24 697.5 24H705Z" fill="currentColor" />
    </g>
    <g>
      <path d="M746.475 22.45C746.492 22.3023 746.5 22.1521 746.5 22V14C746.5 11.7909 744.709 10 742.5 10H737V12H742.5C743.605 12 744.5 12.8954 744.5 14V22C744.5 22.1407 744.485 22.2781 744.458 22.4106L742.432 20.52L741.068 21.98L745.5 26.12L749.932 21.98L748.568 20.52L746.5 22.45H746.475Z" fill="currentColor" />
      <path d="M729.525 13.55C729.508 13.6977 729.5 13.8479 729.5 14V22C729.5 24.2091 731.291 26 733.5 26H739V24H733.5C732.395 24 731.5 23.1046 731.5 22V14C731.5 13.8593 731.515 13.7219 731.542 13.5894L733.568 15.48L734.932 14.02L730.5 9.88L726.068 14.02L727.432 15.48L729.5 13.55H729.525Z" fill="currentColor" />
    </g>
  </svg>
</div>
              
            
!

CSS

              
                *,
*:after,
*:before {
	box-sizing: border-box;
}

:root {
	--scale: calc(2 - (var(--zoom, 0) * 1.5));
	--transition-speed: calc(0.5s + (var(--slow, 0) * 5s));
  --accent: hsl(180 100% 50%);
	--step: steps(20);
}

body {
	display: grid;
	place-items: center;
	min-height: 100vh;
	background: black;
	color: white;
	font-family: sans-serif;
	font-weight: bold;
}

/* Repost button code */
button {
	width: 48px;
	aspect-ratio: 1;
	scale: var(--scale);
	display: grid;
	place-items: center;
	border-radius: 12px;
	border: 0;
	padding: 0;
	cursor: pointer;
	background: var(--bg, hsl(0 0% 100% / 0.1));
	position: fixed;
	top: 50%;
	left: 50%;
	translate: -50% -50%;
	transition: background 0.2s, scale 0.2s;
}

button:is(:hover, :focus-visible) {
	--bg: hsl(0 0% 100% / 0.2);
}

button[aria-pressed=true]:is(:hover, :focus-visible) {
	--bg: hsl(180 100% 50% / 0.2);
}

button img {
	pointer-events: none;
	height: 100%;
	aspect-ratio: 1;
	object-fit: cover;
	filter: invert(0.4) sepia(1) saturate(0) hue-rotate(140deg) brightness(1);
	opacity: 0.8;
	object-position: 0 0;
  position: absolute;
}

[aria-pressed=true] img {
	animation: sprite-play var(--transition-speed) var(--step) forwards;
}

@keyframes sprite-play {
	75% {
		scale: 1.25;
	}
	to {
		opacity: 1;
		filter: invert(0.4) sepia(1) saturate(20) hue-rotate(140deg) brightness(1);
		object-position: 100% 0;
	}
}

.sprite-container {
	position: fixed;
	top: 50%;
	left: 50%;
	translate: -50% -50%;
	transform: scale(var(--scale));
  transition: transform 0.2s;
	width: 48px;
	aspect-ratio: 1;
	border-radius: 12px;
	color: hsl(0 0% 100% / 0.5);
	z-index: -1;
	--clip: calc(var(--show, 0) * -100vmax);
	clip-path: inset(var(--clip) var(--clip) var(--clip) var(--clip));
  transition: clip-path 0.2s;
}

.sprite-container::after {
	content: "";
	position: absolute;
	inset: 0;
	background: black;
}

button {
  outline-color: var(--accent);
}

button[aria-pressed=true] ~ .sprite-container svg {
	translate: calc(-100% + 48px) 0;
	transition: translate var(--transition-speed) var(--step);
}

.sprite-container svg {
	height: 100%;
	position: absolute;
	left: 0;
	opacity: 0.75;
}

.controls {
	display: grid;
	position: fixed;
	top: 1rem;
	right: 1rem;
	grid-template: 1fr 1fr / 1fr auto;
	gap: 0.5rem;
	padding: 1rem;
	accent-color: hsl(165, 100%, 35%);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
              
            
!

JS

              
                const BTN = document.querySelector('button')
const LABEL = BTN.querySelector('span')
const SLOW = document.querySelector('#slow')
const SHOW = document.querySelector('#show')
const ZOOM = document.querySelector('#zoom')
const STEP = document.querySelector('#step')

const TOGGLE = () => {
  BTN.setAttribute(
    'aria-pressed',
    BTN.matches('[aria-pressed=true]') ? false : true
  )
  LABEL.innerText = BTN.matches('[aria-pressed=true]') ? 'Undo Repost' : 'Repost'
}

BTN.addEventListener('click', TOGGLE)

const CHANGE = () => {
  document.documentElement.style.setProperty('--slow', SLOW.checked ? 1 : 0)
  document.documentElement.style.setProperty('--show', SHOW.checked ? 1 : 0)
  document.documentElement.style.setProperty('--zoom', ZOOM.checked ? 1 : 0)
  document.documentElement.style.setProperty('--step', STEP.checked ? 'steps(20)' : 'ease-in-out')
}

SLOW.addEventListener('change', CHANGE)
SHOW.addEventListener('change', CHANGE)
ZOOM.addEventListener('change', CHANGE)
STEP.addEventListener('change', CHANGE)
              
            
!
999px

Console