Zero One Documentation
Theme demo
  • Overview
  • Terms & Guidelines
  • Guide
    • Installation & Setup
      • Local environment
      • Server
      • Default language!
      • Multilanguage website
      • Config options
      • SMTP email options
      • Folder structure
      • htaccess
      • Updating
      • PHP Composer
    • Administration panel
      • Translating panel
    • Site options
      • SEO options
      • Multi-language
    • Theme styling
      • Less/CSS setup
      • Changing Less variables
      • app.less file
      • Customizing elements
      • Helpful classes
    • Page types
      • Page options
    • Blog
      • Comments
      • Article
    • Work (Portfolio)
      • Project page
    • Shop
      • Snipcart
    • Layout Builder
      • Column Options block
      • Subgrid block
      • Card block
      • Text (Writer) block
      • Custom Heading block
      • Custom List block
      • Typed Text block
      • Quote block
      • Button block
      • › 25 more blocks
    • Form Builder (Premium)
    • OLD Page Builder deprecation
    • Tricks
      • Using icons in the content
      • Kirbytext link tag to button
      • Tricks with image classes
      • Adding Google Fonts
      • Custom icons
      • Cookie notice/banner
    • Theme extending
      • Page Transitions (Swup)
      • Contact form extending
      • Self-hosted fonts
      • Adding new templates
      • Adding new Content block (Layout Builder)
    • GDPR
  • More
  • Support
  • Hire us
  • Changelog
  • Credits
  • Affiliate
Powered by GitBook
On this page
  • Build and compile
  • How Swup works?
  • What is the main issue if you extend Zero One and want to use Swup page transitions?

Was this helpful?

  1. Guide
  2. Theme extending

Page Transitions (Swup)

This page is dedicated primarily to developers who are extending Zero One.

PreviousTheme extendingNextContact form extending

Last updated 16 days ago

Was this helpful?

From version we integrated optional page transitions using .

Build and compile

But that's not all there is. We included the whole JS build and compile system in the assets/js/ folder. That system is based on by Chris Ferdinandi, but we extended it further to work also on Windows and to support JS import modules as Parcel for example does it.

You can see everything about how it works by opening assets/js/readme.md file. Although it can do more than just JS, we didn't want to strip other options.

To use it only for JS, there are only three commands you should care about:

  • npm install to instal all dependencies

  • npm run js to build and compile JS

  • npm run watch-js to watch for JS changes

You develop assets/js/src/js/main.js file, it is the main file in which you import all others. You can of course add new subfolders there and import additional JS libraries you need.

After build the compiled files are in the assets/js/dist/js/ folder.

How Swup works?

You can learn more about how Swup works at

Although they say it is an easy library, it actually isn't. Every library that changes the DOM should be integrated with great care and should be thoroughly tested.

We are working for a few years with Swup, and have it live on several websites so we know what we are doing. You can see the Zero One Swup set up in the assets/js/src/js/main.js file.

In Zero One there are three separate containers: #swup (page content + footer), #navbar and #mobile-menu. You will see that navbar stays still while page content changes.

What is the main issue if you extend Zero One and want to use Swup page transitions?

Now, we come to the main reason why this documentation page exists.

Swup library automatically detects all links (<a></a> tags), and do its magic. But... Not all links are links that should be included in the page transitions process. Some links types Swup excludes by default, for example, links that point to a different domain, and we excluded in our setup links that have target="_blank". And that's fine.

But, there are links you need to exclude manually.

Links like modals, toggles, lightbox, etc. Mostly Javascript links.

You do that by adding [data-no-swup] attribute to the link. For example:

// Modal example from Zero One
<div><a href="#modal-full" data-no-swup uk-search-icon uk-toggle></a></div>

We did that everywhere in Zero One where it needs to be added, but when you are extending Zero One and adding your additional templates and code, you should add [data-no-swup] attribute to the link whenever you want that link to exclude from the transition process.

4.1.0
Swup library
Build Tool Boilerplate
https://swup.js.org/getting-started/how-it-works