Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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.

HTML

              
                <!-- Top App Bar -->
<header class="mdc-top-app-bar">
  <div class="mdc-top-app-bar__row">
    <section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start">
      <button class="mdc-top-app-bar__navigation-icon mdc-icon-button material-icons">menu</button>
      <a class="mdc-top-app-bar__title" href="https://www.webdenim.io" target="_blank">Webdenim</a>
    </section>
  </div>

  <div class="mdc-linear-progress mdc-linear-progress--closed" role="progressbar">
    <div class="mdc-linear-progress__buffering-dots"></div>
    <div class="mdc-linear-progress__buffer"></div>
    <div class="mdc-linear-progress__bar mdc-linear-progress__primary-bar">
      <span class="mdc-linear-progress__bar-inner"></span>
    </div>
    <div class="mdc-linear-progress__bar mdc-linear-progress__secondary-bar">
      <span class="mdc-linear-progress__bar-inner"></span>
    </div>
  </div>
</header>

<div class="app-drawer-layout mdc-top-app-bar--fixed-adjust">
  <!-- Content -->
  <main class="mdc-drawer-app-content main-content">
    <div class="article">
      <h1 style="margin: 0;">Scroll the article</h1>
      <p style="margin-top: 1rem; font-size: 1.125rem;">And watch the progress line in the top app bar</p>

      <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>

      <h2>Why do we use it?</h2>
      <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
      <h2>Where does it come from?</h2>
      <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>

      <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</p>

      <h2>Where can I get some?</h2>
      <p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.</p>

      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis congue elementum faucibus. Ut ex eros, aliquam non sollicitudin placerat, facilisis at orci. Vestibulum luctus, dui ut aliquet placerat, nibh dolor posuere orci, et dapibus erat nulla quis neque. Nulla pulvinar felis at diam imperdiet, a efficitur nunc rutrum. Nam at ultrices tellus, in tempus neque. Fusce eu mollis risus. Pellentesque nec arcu augue. Vestibulum iaculis, diam sed rutrum viverra, leo mauris eleifend eros, id eleifend elit nulla non dui. Nulla quis mi tortor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus enim dui, pulvinar eu orci quis, placerat viverra lectus. Nullam accumsan sed nisl non pharetra. Phasellus viverra eu enim sit amet bibendum. Pellentesque vitae faucibus arcu. Morbi sed massa justo. Proin auctor fermentum accumsan.</p>

        <p>Fusce vel nisi lectus. Integer justo elit, scelerisque a convallis sed, accumsan quis metus. Donec euismod ut felis non rhoncus. Maecenas et risus convallis, sagittis metus a, dapibus sapien. Morbi ut purus eu augue porttitor tempor ac quis odio. Proin ac est eu ex fermentum dignissim non fermentum quam. Maecenas volutpat enim eget quam tristique vulputate. Nulla sollicitudin turpis elit, a gravida lectus placerat a. Quisque dapibus dui quis hendrerit congue.</p>

        <p>Nam vitae sodales dui. In hac habitasse platea dictumst. Mauris blandit tempus libero, in mollis velit volutpat et. Cras rhoncus tempor velit eu ultrices. In posuere sapien ac porttitor posuere. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse luctus libero vel felis aliquam fermentum quis id leo. Curabitur vel lobortis nisi. Aliquam fringilla nisi lacus, at bibendum est imperdiet id. In fermentum ante mi, ac pellentesque erat euismod in. Aenean placerat arcu a pellentesque lacinia. Donec dictum leo blandit, porttitor augue ac, fermentum orci. Mauris condimentum placerat leo, sit amet efficitur nunc auctor eu. Duis sem neque, dignissim in convallis sed, dignissim ut sapien. Morbi in dolor ipsum.</p>

        <p>Nulla facilisi. Donec accumsan, justo at bibendum molestie, tortor enim laoreet tellus, luctus ultricies lectus elit ac quam. Sed ultrices libero purus, at sollicitudin enim vulputate eget. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec sollicitudin aliquet ante, eget scelerisque turpis dictum fringilla. Sed facilisis lacus nec maximus porttitor. Vivamus dignissim, risus quis efficitur pretium, sapien metus viverra lectus, et scelerisque dolor augue ac neque.</p>

        <p>Pellentesque et congue nisi. Mauris vitae purus a nisl maximus laoreet at id elit. Ut eget quam id eros euismod dignissim. Donec euismod ornare quam, vitae ultrices tortor dapibus quis. Sed blandit blandit massa, ac pulvinar lectus condimentum sit amet. Donec sed lacus ultricies, consectetur sapien et, blandit tortor. In libero dui, interdum tempor turpis vitae, blandit mattis purus. Cras ac tortor ex. Ut vitae mi vitae enim facilisis tempus. Nam ullamcorper malesuada diam in vestibulum. Pellentesque ut velit vel diam euismod egestas vel at ipsum. Morbi erat quam, porttitor ut feugiat in, placerat nec urna. Cras posuere ex nec ligula fermentum, at lacinia libero mollis.</p>

        <p>Nullam eget orci sit amet purus malesuada pretium et in orci. Vivamus mattis libero id blandit commodo. Donec sapien nulla, eleifend eget leo eu, faucibus hendrerit sem. Vivamus accumsan lectus et dolor lobortis pellentesque. Donec vel felis eget lorem accumsan congue. Suspendisse nec malesuada dolor. Donec porttitor nisl quis nisi pellentesque, in sodales turpis tempor. Aenean sagittis semper nunc in mattis. Vivamus semper quis est eget cursus. Praesent finibus, est eget ultrices malesuada, sapien odio efficitur neque, eu mattis sem urna dictum urna. Curabitur purus dolor, auctor quis pellentesque at, commodo sit amet mauris. In hac habitasse platea dictumst. Integer ut lobortis enim. Quisque a lacus ligula.</p>

      <p>In consequat metus eu tellus interdum, id ullamcorper metus fringilla. Aenean blandit lacus sit amet elementum mollis. Pellentesque et tincidunt sapien. Suspendisse faucibus, nunc finibus cursus feugiat, eros libero laoreet felis, a dictum leo ante nec lacus. Suspendisse pulvinar lobortis dictum. Duis vel augue ut augue congue sodales sed eget leo. Pellentesque viverra erat ac eleifend lacinia. Nulla facilisi. Nam eu sollicitudin quam. Nulla facilisi. Sed malesuada nibh eu mauris faucibus sodales. Nullam euismod at lacus et euismod. Aliquam massa neque, dictum vel feugiat nec, lacinia in purus. Duis a elementum metus. Cras cursus purus in leo consequat elementum.</p>
    </div>
  </main>
</div>

              
            
!

CSS

              
                .mdc-top-app-bar {
  background-color: #fff;
  color: #202124;

  &__title {
    color: inherit;
  }

  &__navigation-icon {
    color: inherit !important;
  }

  .mdc-linear-progress {
    position: absolute;
    bottom: -4px;

    // Remove progress delay
    &__primary-bar {
      transition: none;
    }
  }
}

.article {
  max-width: 600px;
  margin: 0 auto;
  padding: 2.5rem;
  line-height: 1.5rem;

  p {
    margin: 2rem 0;
  }
}

              
            
!

JS

              
                // MDC Linear Progress Instantiation
const linearProgressElement = document.querySelector('.mdc-linear-progress');
const linearProgress = new mdc.linearProgress.MDCLinearProgress(linearProgressElement);

// The scroll progress will be calculated
// based on the height of target element.
const targetElement = document.querySelector('.article');
const topAppBar = document.querySelector('.mdc-top-app-bar');

function initScrollProgress() {
  if (!targetElement) {
    return;
  }

  linearProgress.open();
  window.addEventListener('load', setScrollProgress); // Wait until all images are loaded to get real document height
  window.addEventListener('resize', setScrollProgress);
  window.addEventListener('scroll', setScrollProgress);
};

function getScrollRatio() {
  const el = targetElement.getBoundingClientRect();

  // Disable scroll progress if the element is not tall
  if (el.height / 1.75 < window.innerHeight) {
    return;
  }

  const topAppBarHeight = topAppBar.clientHeight;

  const scrollArea = el.height - window.innerHeight + topAppBarHeight;
  const scrollYPos = window.pageYOffset - (el.top + window.pageYOffset) + topAppBarHeight;
  let scrollRatio = scrollYPos / scrollArea;
  if (scrollRatio > 1) {
    scrollRatio = 1;
  } else if (scrollRatio <= 0) {
    scrollRatio = 0;
  };
  return scrollRatio;
};

function setScrollProgress() {
  linearProgress.progress = getScrollRatio();
};

initScrollProgress();

              
            
!
999px

Console