← Back


A light spiritual succesor to neon-animated-pages using only css animations





Published on webcomponents.orgnpm version

API | Demo | Using it in pwa-starter-kit

This is a light spiritual successor to the now deprecated <neon-animated-pages>.

It works with css animations and only depends on lit-element so you don't have to worry about including any heavy js libraries.

This component takes care of the logic behind triggering the animations so that you can focus on making your views and your animations (or just use the animations included in the sample-animations folder if you don't want to bother with those either �.)

It can be easily used in pwa-starter-kit and here's how.

To begin using it just follow this simple steps:

  • Install it:

    npm i --save helium-animated-pages

  • Import the script:

    In html:

      <!-- Don't forget to include webcomponents loader -->
      <script src="node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
      <!-- type="moodule" is essential -->
      <script type="module" src="node_modules/helium-animated-pages/helium-animated-pages.js"></script>

    In a js module:

      import 'helium-animated-pages/helium-animated-pages.js';
  • Create an instance of <helium-animated-pages> in your HTML page, or via any framework that supports rendering Custom Elements and start using it:

        /* define your animation keyframes and classes
          (you can use the ones provided too)
          these must be defined context that contains
          <helium-animated-pages> */
        /* these only use the standard css animation to keep
         example code short */
        .page-fadeIn {
            animation: fadeIn .7s ease both;
        @keyframes fadeIn {
            from { opacity: 0.3; }
            to { }
        .page-fadeOut {
            animation: fadeOut .7s ease both;
        @keyframes fadeOut {
            from { }
            to { opacity: 0.0; }
        <h2>Select a page</h2>
        <select id="selector">
          <option value="page1">Page 1</option>
          <option value="page2">Page 2</option>
          <option value="page3">Page 3</option>
      <!-- attrForSelected is used to say which attribute
        identifies the pages
        or you can just not use it and use numerical indexes -->
      <helium-animated-pages id="pages" attrForSelected="name">
        <!-- The pages can be almost anything -->
        <section name="page1">Page 1</section>
        <div name="page2">Page 2</div>
        <!-- It is recommended that custom elements
          used as a page all extend an element like pwa-starter-kit's

        <custom-element name="page3"></custom-element>
        // example way of changing pages, you could use a router
        // or any other way you want
          // Change selected page, can also receive and index
          // you can also use selectPrevious() or selectNext()
        // defining the "rules" for which css classes to apply on
        // diferent page transitions, for more info go to:
        // I'm using css classes which aren't defined on this context but you
        // must define them when actually using this
        document.querySelector('#pages').animationClasses = {
          // animation classes rules are like css rules, the most specific ones apply first
          // from page1 to page2
          'page1_page2': {
            in: 'page_moveFromRight',
            out: 'page_moveToLeft'
          // from anything (other than page1 to page2)
          '*_page2': {
            in: 'page_moveFromLeft',
            out: 'page_moveToRight'
          // from page1 to anything (other than page2)
          'page1_*': {
            in: 'page_moveFromTop',
            out: 'page_moveToBottom'
          // from nothing selected to page1
          '_page1': {
            in: 'page_moveFromBottom',
            out: 'page_moveToTop'
          // if none of the rules above apply
          default: {
            in: 'page-fadeIn',
            out: 'page-fadeOut'


Almost all sample animations and the overall flow of the page selection are based on an article by Pedro Botelho@Codrops.


(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.



  • lit-element#^2.0.1
BSD 3-clause "New" or "Revised" License


Browser Independent