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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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.


                <main class="[ container ] [ flow ]">
  <h1>Buy this thing!</h1>
  <p>It is very good and there's absolutely no hidden exceptions!</p>
  <a href="//" class="button">Buy it now!!</a>
  <div class="terms">
    <button class="[ link-button ] [ js-trigger ]" type="button" hidden>
      See the terms & conditions
      <svg viewBox="0 0 512 512" aria-hidden="true" fill="currentColor" width="1em" height="1em">
        <path d="M60 99.333l196 196 196-196 60 60-256 256-256-256z"></path>
    <div class="[ panel ] [ js-panel ]">
      <article class="[ panel__inner ] [ js-panel__inner ]">
        <p>Here's some secret terms and conditions that we didn't want you to see because they explain how the product isn't actually very good. </p>

          Lorem ipsum dolor sit amet, appareat pertinax et ius, ne pro nibh consulatu consetetur, nulla virtute definitiones nec in. Ad consul feugait eligendi mea, mutat tamquam ei mei. No hinc graecis phaedrum pro, cu erat ipsum sed, ut novum dissentiunt
          ullamcorper pro. <a href="#">Dicat aliquid dissentias</a> in per, meis alterum quaestio mei eu, vero praesent ex eam. Ei nam homero noluisse dissentiunt, ut vim quot putent. Vis elitr accusam accommodare id, cu usu quaestio conceptam, habeo tibique placerat eos
          cu. An nullam corpora consulatu qui, graeci euripidis est et.
          In tantas scripta nominati quo, ne essent maluisset voluptaria nam. Dicat putent feugiat ei sed, te vis delicata gubergren honestatis, ius liber blandit delicata ut. Vix et dictas detracto voluptua, vis an inani dicunt. Qui inciderint intellegebat ea,
          cetero verear cu duo.
          Vix id etiam sapientem. Vix case velit feugait eu. Id diceret delenit perpetua vis, has sale utamur aeterno te. Cum et consetetur mediocritatem.


                /* General presentation styles */

html {
  background: #212d40;

.link-button {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";

body {
  padding: 1.5rem;
  line-height: 1.4;
  color: #f3f3f3;

p {
  margin: 0;

article > * + * {
  margin-top: 1.5em;

hr {
  border: none;
  border-top: 1px dashed #ccc;
  margin: 1.5rem 0;

a:not([class]) {
  color: currentcolor;

a:not([class]):focus {
  text-decoration: none;

.container {
  max-width: 30rem;
  margin: 0 auto;

.terms {
  --flow-space: 2rem;

/* Flow utility, which I write about here: */
.flow {
  --flow-space: 1em;

.flow > * + * {
  margin-top: var(--flow-space);

/* Button component */
.button {
  display: inline-block;
  border: none;
  padding: 0.6rem 1.2rem 0.8rem 1.2rem;
  text-decoration: none;
  background: #98b06f;
  color: #212d40;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: background 250ms ease-in-out, transform 150ms ease;
  -webkit-appearance: none;
  -moz-appearance: none;

.button:focus {
  background: #ffffff;

.button:focus {
  outline: 1px solid #212d40;
  outline-offset: -4px;

.button:active {
  transform: scale(0.99);

/* Link button component */

.link-button {
  display: none; /* We hide this button by default / if there's no JS available */
  text-decoration: underline;
  text-decoration-skip-ink: auto;
  background: transparent;
  padding: 0;
  margin: 0;
  border: 0;
  color: #98b06f;
  font-size: 1rem;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;

/* When the link-button has a correct aria attribute, we can show it */
.link-button[aria-expanded] {
  display: inline-flex;
  align-items: center;

.link-button svg {
  opacity: 0.8;
  margin-left: 0.5rem;
  transition: all 250ms ease-in-out;
  font-size: 0.8rem;

.link-button[aria-expanded="true"] svg {
  transform: rotate(-180deg);

.link-button:focus {
  text-decoration: none;

.link-button:focus {
  text-decoration: none;
  outline: 1px solid rgba(255, 255, 255, 0.4);
  outline-offset: 0.6rem;

.link-button:active {
  transform: scale(0.99);

/* Panel component which is completely controlled by a valid sibling 
   button element, such as the link button. We only conceal the content 
   if its sibling button has the correct aria attribute, so we can enforce
   accessibility and progressively enhance the UI */
[aria-expanded] + .panel {
  --panel-max-height: 500px;

  transition: all 200ms ease;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 0;
  visibility: hidden;
  -webkit-overflow-scrolling: touch;

[aria-expanded] + .panel .panel__inner {
  transition: all 500ms ease;
  transition-delay: 50ms;
  opacity: 0;
  transform: translateY(1rem);
  padding-top: 1.5rem;

[aria-expanded="true"] + .panel {
  max-height: var(--panel-max-height);
  visibility: visible;

[aria-expanded="true"] + .panel .panel__inner {
  opacity: 1;
  transform: translateY(0);




const trigger = document.querySelector('.js-trigger');
const panel = document.querySelector('.js-panel');
const panelInner = document.querySelector('.js-panel__inner');

// This is the CSS Custom Property that is updated with the panel's content's height
const maxHeightKey = '--panel-max-height';

let state = {
  triggerExpanded: 'collapsed'

// Sets the relevant aria role based on its current value. Sets it to false by default
// if no value is set
const setTriggerState = () => {
  let currentExpandedState = trigger.getAttribute('aria-expanded');
  // If it's not set yet, set it to true so it is reversed below
  if(currentExpandedState === null) {
    currentExpandedState = 'true';
  // Update our global state so other functions know what's up
  state.triggerExpanded = currentExpandedState === 'true' ? 'false' : 'true'
  trigger.setAttribute('aria-expanded', state.triggerExpanded);

// Looks for content within the panel and calculates its height. This makes the transition smoother.
// Returns a promise so it can do its job before the toggle starts
const setMaxHeight = () => {
  return new Promise((resolve, reject) => {
    if(!panel || !panelInner) {
    }, `${panelInner.getBoundingClientRect().height}px`);

const run = () => {
  .then(() => setTriggerState());

trigger.addEventListener('click', run);