Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ add another resource


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


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.


Save Automatically?

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.


@import url('');

  <h1>Emoji Confetti ๐ŸŽ‰</h1>
  <p>Click the button for a surprise</p>

<div class="main">
  <a class="btn" onclick="create()">Click Me!</a>

<p>&lt;/&gt; by <a href="" target="_blank">DJDMorrison</p>


                .emoji {
  position: absolute;
  top: calc(50% - 10px);
  left: 50%;
  will-change: transform;
  z-index: -1;
  opacity: 1;
  transition: opacity 500ms ease;
  transition-delay: 1s;
  &.show {
    opacity: 0;

// Presentation CSS
body {
  font-family: 'Roboto', sans-serif;
  box-sizing: border-box;
  margin: 0;
  padding: 100px 0;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;

.main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;

.btn {
  background: #049fd9;
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  font-family: sans-serif;
  z-index: 999;
  cursor: pointer;

h1, p {
  margin: 0;
  text-align: center;
  padding: 0 10px;

h1 {
  margin-bottom: 5px;

a {
  color: black;


                // Dot === Emoji

const MS_60FPS = 1000 / 60;

const emojis = ['๐ŸŒˆ', 'โค๏ธ', '๐Ÿงก', '๐Ÿ’›', '๐Ÿ’š', '๐Ÿ’™', '๐Ÿ’œ', '๐ŸคŽ', '๐Ÿ–ค', '๐Ÿค']
const timeout = 3000;
const maxNumDots = 20;
const gravity = .2;

let dots = [];

// Create a new random emoji and give it random velocity and delay
function createDot() {
  const el = document.createElement('div');
  el.innerHTML = emojis[Math.floor(Math.random() * emojis.length)];

  const x = 0;
  const y = 0;
  const vx = -3 + (Math.random() * 6);
  const vy = 5 + Math.random() * 5;
  const delay = Math.random() * 1000;
  return {
    visible: false

// Create a random number of dots and push to dots list
function create() {
  let newDots = [];
  const num = Math.ceil(Math.random() * maxNumDots);
  for (let x = 0; x < num; x++) {
  dots = [...dots, ...newDots];

// for each dot, perform actions depending on it's state 
function update() {
  dots.forEach(dot => {
    // if timeout is below 0, remove from dots list and dom
    if (dot.timeout < 0) {
      dots = dots.filter(d => d !== dot);
    // if the dot is visible, check if it has show class and update it's velocity and position
    if (dot.visible) {
      if (!dot.el.classList.contains('show')) {

      dot.vy -= gravity;

      dot.x += dot.vx;
      dot.y -= dot.vy;

      const transform = `translate(${dot.x}px, ${dot.y}px)`; = transform;
    // if not visible yet, update it's delay and make visible if delay below 0
    else {
      dot.delay -= MS_60FPS;
      if (dot.delay < 0) {
        dot.visible = true;
    dot.timeout -= MS_60FPS;

// Update every 16.66ms to produce 60fps
setInterval(update, MS_60FPS);