# Prevent Content Flash

## Setup

**Attribute**: `sf-noflash = true`

**Where**: [form-container](https://deltaclan.gitbook.io/superform/essentials/form-container "mention") or *any* element

The `sf-noflash` attribute is used to temporarily hide a form and/or form elements while Superform is initializing.&#x20;

This prevents elements from flashing or appearing prematurely before the form is fully interactive and styled, ensuring a smoother user experience. Can be used for any element (eg. errors in initial step)

{% hint style="warning" %}
Additional CSS required. Read below.
{% endhint %}

### Requirements

To make `sf-noflash` effective, include the following CSS in the `<head>` of your HTML document:

#### **CSS &#x20;**<mark style="background-color:red;">**required**</mark>&#x20;

```html
<style>
  [sf-noflash] {
    opacity: 0;
  }
</style>
```

This CSS rule sets  `opacity: 0` to any element with the `sf-noflash` attribute, effectively hiding it on initial load.

### **Can be used to solve:**

1. Steps (in a multistep form) flashing on initial load
2. Error elements flashing on initial load

**HTML Example**

{% code title="index.html" %}

```html
<!-- Form Container with No Flash Settings -->
<div sf="myForm" sf-noflash="true"">
    <form>
        <!-- Step 1 -->
        <div sf-step="step1">
            <!-- Content for Step 1 -->
            <button sf-goto="next">Next</button>
        </div>
        
        <!-- Step 2 -->
        <div sf-step="step2">
            <!-- Content for Step 2 -->
        </div>
    </form>
</div>
```

{% endcode %}

{% code title="styles.css" %}

```css
[sf-noflash] {
  opacity: 0;
}
```

{% endcode %}

**Webflow Example**

<figure><img src="https://450000313-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDGLtnaQr6bP3qHCWvX0r%2Fuploads%2FXO4A5TwT674tYIwtggQC%2FCleanShot%202024-06-22%20at%2021.29.19%402x.png?alt=media&#x26;token=a8872ddc-9fd5-4fa6-ba2c-2846845e5c61" alt=""><figcaption><p>Step 1: Add [sf-noflash] CSS rule in the &#x3C;head> of your page.</p></figcaption></figure>

<figure><img src="https://450000313-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDGLtnaQr6bP3qHCWvX0r%2Fuploads%2FH86STbMNiulqFR08N4rZ%2FCleanShot%202024-06-22%20at%2021.30.58%402x.png?alt=media&#x26;token=08d34475-98f8-448f-9b6a-d42dae985c74" alt=""><figcaption><p>Step 2: Add the <code>sf-noflash = true</code> directive.</p></figcaption></figure>

### 🚫 Without `sf-noflash`

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDGLtnaQr6bP3qHCWvX0r%2Fuploads%2FkI5RPdOCof2nGH6LNU7s%2Fnoflash%20-%20is-flashing.mp4?alt=media&token=c38c045a-284d-4ab1-a60e-ddcba96da8c1>" %}
Initial load without `sf-noflash`
{% endembed %}

### ✅ With `sf-noflash = true`

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDGLtnaQr6bP3qHCWvX0r%2Fuploads%2FEVEKt9ij0Q0nbSxN5tzC%2Fsf_noflash-true.mp4?alt=media&token=7c2f70ad-8aaf-4580-b662-216702119bcd>" %}
