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

              
                <div class="w-full h-screen flex items-center justify-center">
  <div class="accordion w-[644px]">
    <div class="accordion-item border-b border-[#ccc] mb-3">
      <div class="accordion-header bg-gray-300 cursor-pointer flex items-center justify-between p-3 font-inter font-medium hover:bg-gray-200 duration-200 ease-out text-2xl">
        How can I test the Marketing API?<span class="accordion-icon inline-block rotate-0 duration-200 ease-out"><i class="fa-solid fa-chevron-down accordion-icon"></i></span>
      </div>
      <div class="accordion-content bg-gray-100 h-0 overflow-hidden duration-200 ease-out">
        <div class="p-3 text-lg">
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Reiciendis expedita sint laudantium ut
          doloremque molestias pariatur, impedit harum, sequi blanditiis voluptates. Corporis delectus
          possimus necessitatibus. Officia, dolor quaerat minima esse odio ipsam consectetur consequuntur.
        </div>
      </div>
    </div>
    <div class="accordion-item border-b border-[#ccc] mb-3">
      <div class="accordion-header bg-gray-300 cursor-pointer flex items-center justify-between p-3 font-medium hover:bg-gray-200 duration-200 ease-out text-2xl">
        Who should use the Marketing API ? <span class="accordion-icon inline-block rotate-0 duration-200 ease-out"><i class="fa-solid fa-chevron-down accordion-icon"></i></span>
      </div>
      <div class="accordion-content bg-gray-100  h-0 overflow-hidden duration-200 ease-out">
        <div class="p-3 text-xl">
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Qui nam consectetur suscipit
          consequatur debitis dicta. Quae eveniet minus unde facere deserunt aliquid. Voluptatibus tempore
          vitae quaerat dolorem vero possimus earum pariatur cumque dignissimos ex, voluptas laudantium
          adipisci soluta perspiciatis laboriosam, eveniet maiores quo aliquam iusto ullam quos deserunt
          explicabo. Quam!
        </div>
      </div>
    </div>
    <div class="accordion-item border-b border-[#ccc] mb-3">
      <div class="accordion-header bg-gray-300 cursor-pointer flex items-center justify-between p-3 font-medium hover:bg-gray-200 duration-200 ease-out text-2xl">
        Does Facebook charge for Marketing API calls? <span class="accordion-icon inline-block rotate-0 duration-200 ease-out"><i class="fa-solid fa-chevron-down accordion-icon"></i></span>
      </div>
      <div class="accordion-content bg-gray-100 h-0 overflow-hidden duration-200 ease-out">
        <div class="p-3 text-xl">
          Lorem ipsum dolor sit amet, consectetur adipisicing elit. Obcaecati, perspiciatis odit aliquid
          aliquam magnam eaque et accusamus molestiae voluptates voluptatibus? Ex praesentium enim omnis,
          illo aspernatur eius quasi nostrum ut obcaecati voluptatum dolore atque? Enim dolores ipsa neque
          sunt sint a optio consectetur eos sed nesciunt non perspiciatis, doloremque earum!

          Lorem ipsum dolor sit, amet consectetur adipisicing elit. Id, recusandae?
        </div>
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                body {
  font-family: "Inter", sans-serif;
}

.accordion-item.active .accordion-icon {
  transform: rotate(90deg);
}

              
            
!

JS

              
                const accordionItems = document.querySelectorAll(".accordion-item");

accordionItems.forEach((item) => {
  const header = item.querySelector(".accordion-header");
  const content = item.querySelector(".accordion-content");

  header.addEventListener("click", () => {
    // close other items
    accordionItems.forEach((otherItem) => {
      if (otherItem !== item && otherItem.classList.contains("active")) {
        otherItem.classList.remove("active");
        otherItem.querySelector(".accordion-content").style.height = 0;
      }
    });

    item.classList.toggle("active");

    if (item.classList.contains("active")) {
      content.style.height = `${content.scrollHeight}px`;
    } else {
      content.style.height = 0;
    }
  });
});

              
            
!
999px

Console