Easy, lightweight multi-step experiences.

Overview

Steppp

Steppp is a small library for quickly creating multi-step forms, carousels, and other experiences. It emphasizes a flexible developer experience and a small bundle footprint. In fact, this is why "Steppp" has only three "p"s. Any more would've been too much bloat.

Steppp demo

Getting Started

Install Steppp

If you're using a package manager, install it:

yarn add @ramseyinhouse/steppp or npm install @ramseyinhouse/steppp.

Or, you can load it via CDN:

<script src="https://unpkg.com/@ramseyinhouse/steppp"></script>

Set Up Base CSS

In order to Steppp to behave correctly, you'll need the following CSS:

#steppp {
  position: relative;
}

.step {
  display: none;
  position: absolute;
  left: 0;
}

[data-steppp-active] {
  display: block;
}

[data-steppp-wrapper] {
  position: relative;
  overflow: hidden;
}

Usage

Initialize Steppp

To set up a basic instance of Steppp, select an element and pass it to Steppp.

import Steppp from "@ramseyinhouse/steppp";

const element = document.getElementById("targetElement");

Steppp(element);

Set Up Steps

Steps can be configured in three ways. After choosing an option, be sure to add a data-steppp-active attribute to the initial step you'd like to appear.

As direct children of a target element:

<div id="steppp">
  <section data-steppp-active>first</section>
  <section>second</section>
  <section>third</section>
</div>

As direct children within a data-steppp-wrapper element:

<div id="steppp">
  <div data-steppp-wrapper>
    <section data-steppp-active>first</section>
    <section>second</section>
    <section>third</section>
  </div>
</div>

As elements that have a predetermined selector:

<div id="steppp">
  <section data-steppp-active class="step">first</section>
  <form>
    <section class="step">>second</section>
    <section class="step">>third</section>
  </form>
</div>

When choosing this approach, you'll need to pass the selector to the stepSelector option during initialization:

const element = document.getElementById("targetElement");

Steppp(element, {
  stepSelector: ".step",
});

Consider Naming Your Steps

If your multi-step flow will jump around a bit instead of moving through steps in a linear fashion, you'll need to name your individual steps with a data-steppp-name attribute. More on non-linear movement below.

<div id="steppp">
  <section data-steppp-name="first_step" data-steppp-active>first</section>
  <section data-steppp-name="second_step">second</section>
  <section data-steppp-name="third_step">third</section>
</div>

Move From Step to Step

Steppp comes with two API approaches -- an imperative (you dictate when it'll advance in your code) and declarative (behavior is described by setting various data-steppp-* attributes).

Imperative API

Create a new instance by calling Steppp and passing a target element. Functions will be returned for moving forward, backward, or directly to a specific step (see more on this below).

const element = document.getElementById("targetElement");
const { forward, backward, moveTo } = Steppp(element);

document.querySelector("#forward").addEventListener("click", () => {
  forward();
});

document.querySelector("#backward").addEventListener("click", () => {
  backward();
});

document.querySelector("#moveToStepA").addEventListener("click", () => {
  moveTo("step_a");
});

Declarative API

The declarative approach requires that you place data-steppp-forward, data-steppp-backward on the elements you'd like to trigger particular movements.

<div id="steppp">
  <div data-steppp-wrapper>
    <section data-steppp-active>first</section>
    <!-- ...other steps -->
  </div>

  <button data-steppp-forward>Forward</button>
  <button data-steppp-backward>Backward</button>
</div>

You can also tell elements to move Steppp to a particular step when clicked with a data-steppp-to attribute.

<div id="steppp">
  <div data-steppp-wrapper>
    <section data-steppp-active>
      some step
      <button data-steppp-to="third_step">Go to Step</button>
    </section>
    <!-- ...other steps -->
    <section data-steppp-name="third_step">another step</section>
  </div>
  <button data-steppp-backward>Backward</button>
</div>

Customizing the Animation

Steppp relies on the Web Animations API to power step transitions. By default, a simple fade is configured by using frames that change the opacity of the incoming and outgoing steps.

You can control this animation by passing your own frames. If you simply pass an array of frames, the given order will be applied to the incoming step, and the reverse will be used for the outgoing:

const element = document.getElementById("targetElement");

Steppp(element, {
  frames: [{ opacity: "0" }, { opacity: "1" }],
});

But you can also specify enter and exit properties for your frames. These will be used on the appropriate step during the respective transition.

const element = document.getElementById("targetElement");

Steppp(element, {
  frames: {
    enter: [
      { transform: "rotate(0deg)", opacity: 0 },
      { transform: "rotate(360deg)", opacity: 1 },
    ],
    exit: [
      { transform: "rotate(360deg)", opacity: 1 },
      { transform: "rotate(0deg)", opacity: 0 },
    ],
  },
});

Custom Events

Steppp provides several custom events that you can listen for and hook into.

const element = document.getElementById("targetElement");
Steppp(element);
element.addEventListener("steppp:complete", (event) => {
  const { oldStep, newStep, element } = event.detail;
  // Do something interesting now that the step transition is complete.
});

Available Events

These are the events available to you:

Event Name Description
steppp:invalid This event fires when a step transition fails to start because the current step is invalid.
steppp:abort This event fires when a step transition fails to start because the next step cannot be determined.
steppp:start This event fires when a step transition starts.
steppp:complete This event fires when a step transition completes.

Try It Out!

There's a demo out on StackBlitz. Tinker as much as you want!

https://stackblitz.com/edit/steppp

You might also like...

Remix enables you to build fantastic user experiences for the web and feel happy with the code that got you there. Get a jumpstart on Remix with this workshop.

๐Ÿ’ฟ Remix Fundamentals Build Better websites with Remix Remix enables you to build fantastic user experiences for the web and feel happy with the code

Dec 25, 2022

Easy responsive tabs - is a lightweight jQuery plugin which optimizes normal horizontal or vertical tabs to accordion on multi devices

Easy responsive tabs - is a lightweight jQuery plugin which optimizes normal horizontal or vertical tabs to accordion on multi devices like: web, tablets, Mobile (IPad & IPhone). This plugin adapts the screen size and changes its action accordingly.

Dec 8, 2022

How to implement Step-up Authentication using Amazon Cognito

How to implement Step-up Authentication using Amazon Cognito

How to implement Step-up Authentication using Amazon Cognito This repository contains accompanying source code for the AWS Blog post, How to implement

Dec 15, 2022

AWS Step Functions Workflows Collection

AWS Step Functions Workflows Collection This repo contains Step Functions workflows that shows how to orchestrate multiple services into business-crit

Dec 25, 2022

Hadmean is an internal tool generator. It is language agnostic, schema driven, extremely customizable, featured packed, user-friendly and has just one installation step.

Hadmean is an internal tool generator. It is language agnostic, schema driven, extremely customizable, featured packed, user-friendly and has just one installation step.

Hadmean Report a Bug ยท Request a Feature ยท Ask a Question Table of Contents About Quick Demo Motivation Why you should try Hadmean Getting Started Pre

Dec 29, 2022

VSCode Extension - Preview for AWS Step Functions

VSCode Extension - Preview for AWS Step Functions

VS Code - AWS Step Functions Preview This extension lets you see what your state machine looks like in graphical format. This will help you in writing

Sep 19, 2022

A refined tool for exploring open-source projects on GitHub with a file tree, rich Markdown and image previews, multi-pane multi-tab layouts and first-class support for Ink syntax highlighting.

A refined tool for exploring open-source projects on GitHub with a file tree, rich Markdown and image previews, multi-pane multi-tab layouts and first-class support for Ink syntax highlighting.

Ink codebase browser, "Kin" ๐Ÿ” The Ink codebase browser is a tool to explore open-source code on GitHub, especially my side projects written in the In

Oct 30, 2022

proxy ๐Ÿฆ„ yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner

proxy ๐Ÿฆ„ yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner

proxy ๐Ÿฆ„ yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner. Batteries are included, Content Spinning and Caching Engine, all housed within a stunning web GUI. A unique high-performance, plug-and-play, multi-threaded website mirror and article spinner

Dec 30, 2022

EggyJS is a Javascript micro Library for simple, lightweight toast popups focused on being dependency-less, lightweight, quick and efficient.

EggyJS EggyJS is a Javascript micro Library for simple, lightweight toast popups. The goal of this library was to create something that meets the foll

Jan 8, 2023
Comments
  • Migrate from Jest to Vitest.

    Migrate from Jest to Vitest.

    Description of Proposed Changes

    • Migrate from Jest to Vitest for simpler testing and fewer dependencies.
    • Set up lint-staged for precommit code formatting.
    opened by alexmacarthur 0
  • data-steppp-wrapper typo in examples

    data-steppp-wrapper typo in examples

    Description of Proposed Changes

    There are a few instances of data-stepppp-wrapper, seems like they should be data-steppp-wrapper.

    Related Issue (if applicable)

    N/A

    Testing Steps

    opened by calebroseland 0
  • Clearer error?

    Clearer error?

    Proposed Feature or Bug

    It was not clear from an error I was getting in the console that the data-steppp-active attribute wasn't correctly added to the first step. It would be nice to have a clearer error.

    opened by sjohnson1996 0
Releases(v0.0.4)
  • v0.0.4(Aug 3, 2022)

    What's Changed

    • Migrate from Jest to Vitest. by @alexmacarthur in https://github.com/RamseyInHouse/steppp/pull/5
    • Create LICENSE by @alexmacarthur in https://github.com/RamseyInHouse/steppp/pull/7
    • Update docs, update default transition. by @alexmacarthur in https://github.com/RamseyInHouse/steppp/pull/8
    • fix types by @alexmacarthur in https://github.com/RamseyInHouse/steppp/pull/9

    Full Changelog: https://github.com/RamseyInHouse/steppp/compare/v0.0.3...v0.0.4

    Source code(tar.gz)
    Source code(zip)
Full source-code for the step-by-step tutorial on how to use Phaser + Colyseus together.

Phaser: Real-time Multiplayer with Colyseus Full source-code for the step-by-step tutorial on how to use Phaser + Colyseus together. Live Demo See ste

Colyseus 19 Dec 24, 2022
A simple step by step tooltip helper for any site

Tooltip Sequence A minimalistic set of tooltips on your app. What it does So suppose you create a Web Application and you want to take your users or a

Sooraj Sivadasan Nair 299 Dec 21, 2022
A light-weight user's step-by-step guide for your website using Vanilla JS.

WebTour JS A light-weight user's step-by-step guide for your website using Vanilla JS. Features User's walkthrough - can be used to guide user's to yo

JM de Leon 23 Nov 21, 2022
Multi-step wizard helpers for Alpine.js

Alpine Wizard This package provides an Alpine directive (x-wizard) and a magic helper ($wizard) that allow you to quickly build multi-step wizards usi

Galahad 74 Dec 23, 2022
... a contemporary perspective on how to integrate B2C Commerce and the Salesforce Customer 360 Platform to power frictionless customer experiences in the B2C domain.

Salesforce B2C Commerce / Customer 360 Platform Integration Introduction Salesforce B2C Commerce / CRM Sync is an enablement solution designed by Sale

Salesforce CommerceCloud 45 Dec 9, 2022
Markdoc is a Markdown-based syntax and toolchain for creating custom documentation sites and experiences.

A powerful, flexible, Markdown-based authoring framework. Markdoc is a Markdown-based syntax and toolchain for creating custom documentation sites and

Markdoc 5.8k Jan 2, 2023
A framework for building collaborative Microsoft Teams and M365 experiences.

Live Share SDK The Live Share SDK is in preview. You will need to be part of the Developer Preview Program for Microsoft Teams to use this feature. Th

Microsoft 65 Jan 1, 2023
Demo for my talk "Stream Away the Wait" โ€“ a talk about making excellent pending experiences.

?? Stream Away the Wait When implementing the design of a user interface, we often finish before remembering that not everyone's running the app's ser

Kent C. Dodds 25 Nov 1, 2022
The front-end CSS framework for building experiences for Office and Microsoft 365.

Office UI Fabric Core The front-end framework for building experiences for Office and Office 365. Fabric is a responsive, mobile-first collection of s

Office Developer 3.7k Dec 20, 2022
Remix enables you to build fantastic user experiences for the web and feel happy with the code that got you there. In this workshop, we'll look at some more advanced use cases when building Remix applications.

?? Advanced Remix Workshop Remix enables you to build fantastic user experiences for the web and feel happy with the code that got you there. In this

Frontend Masters 167 Dec 9, 2022