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

              
                <!-- Stuffed all the emoji into aria-hidden spans because wow -->
<!-- were those verbose and not very helpful on their own.    -->

<div class="menu">
  <button class="menu-toggle" aria-expanded="false" id="radialTrigger" aria-controls="radialItems" onclick="toggleDisclosure(this.id);">
    <span aria-hidden="true">➕</span>
    <div class="sr-only">menu trigger</div>
  </button>
  <ul class="menu-items" id="radialItems" inert>
    <li class="item">
      <button>
        <span aria-hidden="true">♥️</span>
        <div class="sr-only">add to favorites</div>
      </button>
    </li>
    <li class="item">
      <button>
        <span aria-hidden="true">💾</span>
        <div class="sr-only">save to collection</div>
      </button>
    </li>
    <li class="item">
      <button>
        <span aria-hidden="true">🔗</span>
        <div class="sr-only">copy link</div>
      </button>
    </li>
    <li class="item">
      <button>
        <span aria-hidden="true">✉️</span>
        <div class="sr-only">email</div>
      </button>
    </li>
    <li class="item">
      <button>
        <span aria-hidden="true">🛒</span>
        <div class="sr-only">add to cart</div>
      </button>
    </li>
  </ul>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Noto+Emoji:wght@600&display=swap');

:root {
  --btn-size: 2.5rem;
  --extra-space: 1.2rem;
}

/* Where the magic happens */
.item {
  --radius: calc(var(--btn-size) + var(--extra-space));
  background-color: var(--bg);
  transform: translateX(calc(cos(var(--angle)) * var(--radius)))
		         translateY(calc(sin(var(--angle) * -1) * var(--radius)))
             rotate(0deg);
/*  Commented out so I can move to a prefers-reduced-motion  */
/*  FQ _and_ make it transition only the transform so the    */
/*  focus/hover states are immediate.                        */
/*   transition: all 0.3s var(--delay) ease; */
}

/* Every item gets a background, angle, and delay */

.item:nth-child(1) {
  --bg: pink;
  --angle: 0deg;
  --delay: 0s;
}

.item:nth-child(2) {
  --bg: thistle;
  --angle: 45deg;
  --delay: 0.1s;
}

.item:nth-child(3) {
  --bg:	paleturquoise;
  --angle: 90deg;
  --delay: 0.2s;
}

.item:nth-child(4) {
  --bg: lightgreen;
  --angle: 135deg;
  --delay: 0.3s;
}

.item:nth-child(5) {
  --bg: peachpuff;
  --angle: 180deg;
  --delay: 0.4s;
}


/* ------------------- */
/* Accessibility fixes */

/* .menu:not(:focus-within) .item */
/* Replaced above selector with one that keys off     */
/* programmatic state of button (disclosure trigger). */
.menu-toggle[aria-expanded="false"] + .menu-items .item {
  --radius: 0;
  --angle: 0;
  rotate: 45deg;
}

/* These styles keep it from failing WCAG SC 2.4.7   */
/* since the focus-visible selector meant it did not */
/* always fire (and never on hover).                 */
.menu-toggle:focus, .menu-toggle:hover, .item:hover, .item:focus-within {
  outline: 2px dashed deeppink;
}

/* Fixed this class to not use a negative left because */
/* I kinda thought the industry knew better by now.    */
.sr-only:not(:focus):not(:active) {
  position: absolute;
  overflow: hidden;
  clip: rect(0 0 0 0); 
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  white-space: nowrap; 
}

/* See line 15. Essentially only allowing animationg for   */
/* users who have not disabled animations and also making  */
/* animation fire only for transform so focus/hover styles */
/* are immediate.                                          */
@media (prefers-reduced-motion: no-preference) {
  .item {
    transition: all 0.3s var(--delay) ease,
      outline 0s 0s linear;
  }
}
/* / Accessibility fixes */
/* --------------------- */




/* Blah blah */

.item {
  border-radius: 50%;
  width: var(--btn-size);
  aspect-ratio: 1/1;
}

.menu-toggle {
  border-radius: 50%;
  width: var(--btn-size);
  aspect-ratio: 1/1;
  background: darksalmon;
  z-index: 1;
}

/* Grid piles */

.menu,
.menu-items,
body,
.item {
  display: grid;
  place-content: center;
}

.menu > *,
.menu-items > *,
body > *
.item button {
  grid-area: 1/1;
}

/* Resets, etc. */

/* Nope, this has gotta go. Very bad. */
/* .sr-only {
  position:absolute;
  left:-10000px;
  top:auto;
  width:1px;
  height:1px;
  overflow:hidden;
} */

button {
  border: none;
  background: none;
  font-family: 'Noto Emoji';
  color: #222;
  font-size: 1.25rem;
}

button:focus-visible {
/*  Moved to a different selector; see line 69.  */
/*   outline: 2px dashed deeppink; */
  border-radius: 50%;
  aspect-ratio: 1/1;
}

body {
  height: 90vh;
}
              
            
!

JS

              
                function toggleDisclosure(btnID) {
  // Get the button that triggered this
  var theButton = document.getElementById(btnID);
  // Get the element it controls
  var theContainer = document.querySelector("#" + btnID + " + ul");
  // If the button is not expanded...
  if (theButton.getAttribute("aria-expanded") == "false") {
    // Now set the button to expanded
    theButton.setAttribute("aria-expanded", "true");
    // Now make container available
    theContainer.removeAttribute("inert");
  // Otherwise button is not expanded...
  } else {
    // Now set the button to collapsed
    theButton.setAttribute("aria-expanded", "false");
    // Now hide the container
    theContainer.setAttribute("inert", "true");
  }
}

// crappy code for closing on Esc
function closeAllDisclosures() {
  var openDs = document.querySelectorAll("button[aria-expanded]");
  for (var i = 0; i < openDs.length; i++) {
    if (openDs[i].getAttribute("aria-expanded") == "true") {
      openDs[i].setAttribute("aria-expanded", "false");
//    Yeah, I got lazy.
      document.querySelector("button[aria-expanded] + ul").setAttribute("inert", "true");
      openDs[i].focus();
    }
  }
}

document.onkeydown = function(evt) {
   if (evt.keyCode == 27) {
    closeAllDisclosures();
  }
};
              
            
!
999px

Console