layer-groupSlide

Add slides to easily create multi-step forms.

Basic usage

The slide() function creates a new slide at the point where it is called. This means that anything after this function will be placed automatically within a new slide, until another slide() function is called (which would create another new slide), and so on. Each slide can contain form fields, content, and custom settings like logic jumps, progress indicators, etc.

In the example below, the second slide will contain the referralSource and have the progress indicator set to half-complete (or 50%). The third slide will contain the recommender, but it will only be shown to the user if they pick "Recommendation" in the second slide. An end slide with a thank you message is automatically added to every form, though this can be customized.

Slide 1
Slide 2
Slide 3 (only shown if the user was recommended)

Generates the following Markdown-like syntax:


Function overview

The following is the overview of the function:

Arguments

Name
Type
Description

params

object

An object containing all the configuration parameters for your slide (see the parameters section below for the full list of options).


Parameters

Name
Type
Description

jumpCondition

string

Logic jump condition that must be true for slide to be shown. This must be a valid Nunjucksarrow-up-right expression.

pageProgress

string

Progress indicator shown on top (e.g. "50%" or "1/2"). Format is percentage or fraction.

buttonAlignment

"start" | "center" | "end" | "stretch"

Set the alignment of this slide's CTA button.

post

true (boolean)

Can be used for slide-level or partial submissions. When set, posts form data up to this slide when going to the next one. See example.

disablePrevious

true (boolean)

When set, disables the previous button.


Examples

Slide with logic jump

In the example below, the second slide will only be shown to the user if they are older than 18. Please note, the jumpCondition parameter must be a valid Nunjucksarrow-up-right expression.

Generates the following Markdown-like syntax:

Slide with progress indicator

In the example below, the progress indicator will be set to half-complete (or 50%) within the second slide because of the pageProgress parameter.

Generates the following Markdown-like syntax:

Slide with button alignment

In the example below, the submit button will be centered within the second slide because of the buttonAlignment parameter.

Generates the following Markdown-like syntax:

Please note, this slide-level buttonAlignment parameter will take precedence over the buttonAligment form setting (which can be used to set the button alignment of every single slide globally).

Slide-level or partial submission

A slide-level or partial submission is when the user completes a slide and goes to the next one, all the form data up to that slide will be sent to the POST URL. Use the post parameter to do slide-level submissions. In the example below, when the user enters their email and goes to the next slide, their accountEmail will be sent to /api/verify-email. Once they enter the verificationCode, the form data will again be sent to /api/verify-email.

Generates the following Markdown-like syntax:

Slide with disabled previous button

In the example below, the previous button (in the footer) will be disabled within the second slide because of the disablePrevious parameter.

Generates the following Markdown-like syntax:

Slide with multiple parameters

Generates the following Markdown-like syntax:

Last updated