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

              
                <button
      popuptoggletarget="drawer"
      class="nav-control"
      aria-haspopup="true"
      aria-expanded="false"
      aria-controls="nav"
      aria-pressed="true"
    >
      <span>Menu Collapsed</span><span>Menu Expanded</span
      ><svg class="nav__icon" viewBox="0 0 24 24" role="img">
        <title>Menu icon</title>
        <path
          d="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z"
          fill="var(--color)"
        ></path>
        <path
          d="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z"
          fill="var(--color)"
        ></path>
      </svg>
    </button>
    <nav class="menu" id="drawer" popup>
      <ul>
        <li>Home</li>
        <li>About</li>
        <li>Writing</li>
      </ul>
    </nav>
    <header>
      <h1>Some Awesome Site</h1>
    </header>
    <main>
      <p>
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Recusandae
        voluptatibus non aut cum eos optio inventore alias velit exercitationem
        sit placeat vel magnam maxime illo ratione fuga, nobis, quibusdam
        officia!
      </p>
      <p>
        Optio ea dolorem qui, necessitatibus, similique cupiditate. Animi fuga
        exercitationem hic aperiam corrupti minus sunt inventore dignissimos
        laborum non, sequi eligendi libero quas totam doloribus officia ipsum,
        nihil placeat rem.
      </p>
      <p>
        Praesentium laboriosam cumque natus adipisci amet asperiores mollitia
        sit consequatur, excepturi deleniti dolores, vitae. Tenetur inventore
        officia, iusto illo, vitae sit fugit vero consequatur molestias, atque
        nulla, eaque aliquam sapiente.
      </p>
      <p>
        Quam necessitatibus aut sit, nesciunt doloribus? Reprehenderit, illum?
        Velit distinctio non adipisci modi libero nostrum placeat fuga dolorem,
        eveniet, ab praesentium nemo, amet. Dolores porro blanditiis doloribus
        perferendis praesentium impedit.
      </p>
      <p>
        Dolores ratione quaerat veniam placeat aut quidem blanditiis nisi
        ducimus distinctio soluta ut, inventore nobis ex dolorem modi
        accusantium architecto vero, voluptas! Cupiditate porro maxime eius,
        suscipit esse sit, rerum.
      </p>
    </main>
              
            
!

CSS

              
                :root {
  --open: 0;
  --bg: var(--gray-9);
  --text-1: var(--gray-1);
  --text-2: var(--gray-1);
  --color: var(--gray-1);
  --header-gradient: var(--gradient-1);
  --hover-action: var(--gray-7);
  --nav-color: var(--gray-8);
  --link: var(--red-3);
}

[aria-pressed] {
  background: none;
  border-radius: 50%;
  position: fixed;
  top: 1rem;
  right: 1rem;
}

[aria-pressed]:hover {
  background: var(--hover-action);
}

body {
  background: var(--bg);
  display: grid;
  color: var(--color);
  align-items: start;
  justify-items: center;
  min-height: 100vh;
  grid-auto-rows: min-content;
  overflow-x: hidden;
}

nav {
  padding: var(--size-2) 0;
  background: var(--nav-color);
  position: fixed;
  top: 0;
  width: 200px;
  bottom: 0;
  box-shadow: var(--inner-shadow-4);
  left: calc(100% - 200px);
  height: 100vh;
  color: var(--gray-0);
}

[popup] {
	--x: 100;
	--speed: 200ms;
  transition: transform var(--speed);
	transform: translateX(calc(var(--x) * 1%));
}

[popup]:top-layer {
  --x: 0;
}

nav::backdrop {
  background: hsl(0 0% 15% / 0.2);
  backdrop-filter: blur(4px);
  animation: fade-in 0.25s ease-in;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

header {
  padding: var(--size-12) 0;
  background: var(--header-gradient);
  width: 100%;
  display: grid;
  place-items: center;
}

:where(h1) {
  text-align: center;
  width: 100%;
  font-size: var(--font-size-6);
}

:where(p, ul) {
  font-size: var(--font-size-0);
  max-inline-size: var(--size-content-2);
}

nav ul {
  list-style-type: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  padding: 0;
  margin: 0;
  width: var(--size-xl);
  gap: var(--size-4);
}

ul li:hover {
  text-decoration: underline var(--size-1) var(--color);
}

button {
  height: 48px;
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  padding: 0;
}

button span {
  position: absolute;
  inset: 0;
  opacity: 0;
  color: transparent;
}

p {
  margin-top: var(--size-4);
}

[aria-pressed] :is(span, svg title, svg path) {
  display: none;
}

[aria-pressed="false"] :is(span:nth-of-type(1), title:nth-of-type(1), path:nth-of-type(1)),
[aria-pressed="true"] :is(span:nth-of-type(2), title:nth-of-type(2), path:nth-of-type(2)){
  display: block;
}

button svg {
  height: 75%;
  stroke: none;
}
              
            
!

JS

              
                const NAV_CONTROL = document.querySelector('button')

const CONTROL_NAV = () => {
	NAV_CONTROL.setAttribute('aria-expanded', NAV_CONTROL.matches('[aria-expanded="false"]') ? true : false)
	NAV_CONTROL.setAttribute('aria-pressed', NAV_CONTROL.matches('[aria-expanded="false"]') ? true : false)
}

NAV_CONTROL.addEventListener('click', CONTROL_NAV)
              
            
!
999px

Console