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

              
                <main id="main"></main>
              
            
!

CSS

              
                //// Global styles ////

:root {
    --animations-time: .4s;
    --icon-stroke-width: 8;
  
    --color-dark: hsl(240, 1%, 28%);
    --color-light: hsl(280, 43%, 99%);
    --color-brand: hsl(5, 65%, 50%);
    --color-brand-02: hsla(5, 65%, 50%, .2);
}

html {
  font-size: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  color: var(--color-dark);
}

body {
  background: var(--color-dark);
  display: flex;
  min-height: 100vh;
  padding: 0;
  margin: 0;
}

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

main {
  background: var(--color-light);
  width: 360px;
  max-width: 100%;
  height: 640px;
  margin: auto;
}


//// Navigation ////

nav {
  max-height: 4rem;
  padding: .5rem;
  overflow: hidden;
}

ul {
  list-style: none;
  margin: 0;
  padding: 2rem;
  width: 100%;
  text-align: center;
  opacity: 0;
  transition: var(--animations-time);  
  
  li {
    font-size: 1.5rem;
    font-weight: 400;
    padding: 1.25rem 3rem;
  }
}


//// Icon ////

button {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  border-radius: 50%;
  transition: var(--animations-time);  
  &:focus {
    outline: none;
    background: var(--color-brand-02);
  }
}

svg {
  width: 3rem;
  height: 3rem;
  display: block;
}

#middleBarCircle, #topLine, #bottomLine {
  stroke: var(--color-brand);
  stroke-width: var(--icon-stroke-width);
  transition: var(--animations-time);
  stroke-linecap: round;
}

#middleBarCircle{
  stroke-dashoffset: 0;
  stroke-dasharray: 112, 2000;
}


//// Open navigation state ////

nav.open {
  max-height: 100vh;

  #middleBarCircle {
    stroke-dasharray: 600, 2000;
    stroke-dashoffset: -270;
  }

  #topLine {
    transform: translate(65px, -10px) rotate(45deg);
  }

  #bottomLine {
    transform: translate(-64px, 64px) rotate(-45deg);
  }

  ul {
    opacity: 1;
  }
}
              
            
!

JS

              
                const Navigation = ({ items }) => {
  const [isOpen, setIsOpen] = React.useState(false);
  return (
    <nav className={`${isOpen ? 'open' : ''}`}>
        <button onClick={() => setIsOpen(!isOpen)} aria-label="Menu">
          <svg id="icon" width="184" height="184" viewBox="0 0 184 184" fill="none" xmlns="http://www.w3.org/2000/svg">
            <g id="close">
              <path id="topLine" d="M36 54H148"/>
              <path id="bottomLine" d="M36 130H148"/>
            </g>
            <path id="middleBarCircle" d="M36 92H147.5C161 92 179.5 83.4 179.5 59C179.5 28.5 144 4 92 4C43.3989 4 4 43.3989 4 92C4 140.601 43.3989 180 92 180C140.601 180 180 140.601 180 92C180 43.3989 141.601 4 93 4"/>
          </svg>
        </button>
        <ul>
          {items.map(function(m, index) {
            return <li>{m}</li>;
          })}
        </ul>
      </nav>
  );
}
  
ReactDOM.render(
  <Navigation items={['Features', 'Services', 'About', 'Contact']} />,
  document.getElementById('main')
);
              
            
!
999px

Console