Skip to content

Embed and style a form

Steps for

Add a form to your store

Most Shopify stores should use the SparkLayer Form block. In the theme editor, you pick a form and set common layout and styling options, without adding code.

  1. In the SparkLayer Dashboard, open the form from Forms (opens in your SparkLayer Dashboard in a new tab). Go to the Embed tab and click Open theme editor. Or, in your Shopify admin, go to Online Store,Themes (opens in your Shopify admin in a new tab) and click Customize.
  2. Open the page where you want the form, and add the SparkLayer Form block to a section.
  3. Select the form you want to show.
  4. Adjust the styling options in the block's settings.
  5. Click Save. The form is now on your store.

When you publish changes to the form later, they show on your store straight away. To share the form as a link instead, click Copy registration link on the Embed tab.

If your form isn't in the block's dropdown, open the SparkLayer Wholesale app under Sales channels in your Shopify admin and accept any new permissions it asks for.

For more control, use the embed code instead: see the Other platforms tab.

Translate a form

A form's Language setting (on the Settings tab) only translates built-in text, such as buttons and the address lookup. The labels, descriptions and messages you write stay as you wrote them. Forms aren't covered by the Core Script translations either. On Shopify, Translate & Adapt can't translate a form's field labels, because the form loads as an embed.

To show a form in several languages, make one form per language:

  1. At Forms (opens in your SparkLayer Dashboard in a new tab), open the form's ⋯ menu and click Duplicate. Make one copy for each language.
  2. In each copy, rewrite the labels, descriptions, button text and success message in that language, and set its Language if it's listed. See Configure form settings.
  3. Publish each copy.
  4. Copy each form's embed code from its Embed tab (under Another website, Copy code).

Then show each language's form on your store:

These steps are for the B2B login page, with your default language's embed code in its Custom Contact Form HTML setting.

  1. Open Shopify's Translate & Adapt app (opens in a new tab) and choose a language at the top.
  2. Under Theme, click Templates, then select Page: B2B Login.
  3. Find the field Main: Custom Form Html and paste that language's embed code.
  4. Save, then repeat for each language.

Your theme needs a language selector, so customers can switch language and see the right form.

Entries arrive on each copy separately, so check the entries of every language's form.

Style a form

Forms match the rest of SparkLayer on your store automatically, so most stores don't need to change anything.

Shopify only

On Shopify, the SparkLayer Form block also has styling options you can set in the theme editor, without code.

To make forms look different from the rest of SparkLayer, your developer or agency can set CSS variables.

Code for your developer

Embedded forms use the same core CSS variables as the rest of SparkLayer. If the SparkLayer Core Script already sets --spark-* variables on your storefront, forms pick them up automatically. See Customising the design for your global styles.

To style forms differently from the rest of SparkLayer, set --spark-form-* variables on the spark-form element. Styles are applied in this order of priority:

  1. --spark-form-* form-specific variables
  2. --spark-* global SparkLayer variables
  3. SparkLayer's default styles

For example:

spark-form {
  --spark-form-max-width: 680px;
  --spark-form-button-color: #000000;
  --spark-form-button-raised-background: #000000;
  --spark-form-button-raised-color: #ffffff;
  --spark-form-link-color: #000000;
  --spark-form-border-radius-default: 4px;
}

See Form CSS variables for every variable.

Embed a form manually (for developers)

This section is for your developer or agency, when they add the form by hand or need its options. The embed code has two parts. First, the SparkLayer form script:

<script src="https://cdn.sparklayer.io/spark-form.v1.js"></script>

Then the form itself, placed where you want it to appear:

<spark-form
form-id="your-form-id"
site-id="your-site-id">
</spark-form>

Your site ID is in Account settings.

Embed attributes

AttributeRequiredWhat it does
form-idYesThe ID of the form to show.
site-idYesYour SparkLayer site ID.
site-envNoSet to test to load the form from your test environment. Defaults to live.
entry-idNoResumes an existing entry.
entry-keyNoThe key needed to open an existing entry.
hide-titleNoSet to true to hide the form title.
preview-version-idNoPreviews a specific form version.

Form CSS variables (for developers)

Each form variable falls back to the matching global variable when it isn't set.

All form CSS variables
Form variableFalls back toControls
--spark-form-max-widthNoneMaximum form width
--spark-form-button-widthNoneButton width, for example 100%
--spark-form-font-default--spark-font-defaultMain font family
--spark-form-header-font--spark-header-fontHeading font family
--spark-form-button-font-family--spark-button-font-familyButton font family
--spark-form-font-default-size-small--spark-font-default-size-smallBase font size on smaller screens
--spark-form-font-default-size--spark-font-default-sizeBase font size
--spark-form-input-font-size--spark-input-font-sizeInput font size
--spark-form-h1-fontsize--spark-h1-fontsizeH1 size
--spark-form-h2-fontsize--spark-h2-fontsizeH2 size
--spark-form-h3-fontsize--spark-h3-fontsizeH3 size
--spark-form-h4-fontsize--spark-h4-fontsizeH4 size
--spark-form-h5-fontsize--spark-h5-fontsizeH5 size
--spark-form-h6-fontsize--spark-h6-fontsizeH6 size
--spark-form-button-small-font-size--spark-button-small-font-sizeSmall button font size
--spark-form-button-font-size--spark-button-font-sizeDefault button font size
--spark-form-button-large-font-size--spark-button-large-font-sizeLarge button font size
--spark-form-font-weight-default--spark-font-weight-defaultDefault font weight
--spark-form-font-weight-medium--spark-font-weight-mediumMedium font weight
--spark-form-font-weight-heavy--spark-font-weight-heavyHeavy font weight
--spark-form-header-font-weight--spark-header-font-weightHeading font weight
--spark-form-button-font-weight--spark-button-font-weightButton font weight
--spark-form-header-text-transform--spark-header-text-transformHeading text transform
--spark-form-header-letter-spacing--spark-header-letter-spacingHeading letter spacing
--spark-form-button-text-transform--spark-button-text-transformButton text transform
--spark-form-button-text-letter-spacing--spark-button-text-letter-spacingButton letter spacing
--spark-form-border-radius-default--spark-border-radius-defaultDefault border radius
--spark-form-border-radius-button--spark-border-radius-buttonButton border radius
--spark-form-input-padding--spark-input-paddingInput padding
--spark-form-button-padding--spark-button-paddingButton padding
--spark-form-product-card-button-padding--spark-product-card-button-paddingProduct card button padding
--spark-form-lightest-color--spark-lightest-colorForm background and light surfaces
--spark-form-default-body-color--spark-default-body-colorBody text colour
--spark-form-header-color--spark-header-colorHeading colour
--spark-form-primary-color--spark-primary-colorPrimary colour
--spark-form-primary-color-light--spark-primary-color-lightLight primary colour
--spark-form-primary-color-dark--spark-primary-color-darkDark primary colour
--spark-form-secondary-color--spark-secondary-colorSecondary colour
--spark-form-link-color--spark-link-colorLink colour
--spark-form-button-color--spark-button-colorButton brand colour
--spark-form-button-raised-color--spark-button-raised-colorPrimary button text colour
--spark-form-button-raised-background--spark-button-raised-backgroundPrimary button background
--spark-form-button-raised-hover-background--spark-button-raised-hover-backgroundPrimary button hover background
--spark-form-button-raised-border-color--spark-button-raised-border-colorPrimary button border colour
--spark-form-button-disabled-color--spark-button-disabled-colorDisabled button text colour
--spark-form-button-large-color--spark-button-large-colorLarge button colour
--spark-form-input-background--spark-input-backgroundInput background
--spark-form-input-border-color--spark-input-border-colorInput border colour
--spark-form-input-text-color--spark-input-text-colorInput text colour
--spark-form-input-focus-border-color--spark-input-focus-border-colorFocused input border colour
--spark-form-table-header-background-color--spark-table-header-background-colorTable header background
--spark-form-success-color--spark-success-colorSuccess state colour
--spark-form-error-color--spark-error-colorError state colour
--spark-form-warn-color--spark-warn-colorWarning state colour
--spark-form-info-color--spark-info-colorInfo state colour
--spark-form-agent-color--spark-agent-colorAgent state colour
--spark-form-company-users-color--spark-company-users-colorCompany users state colour

FAQs

Was this page helpful?

Last updated