Gravity Forms is one of the most powerful form plugins for WordPress, but its default loading indicator can be somewhat underwhelming. In this tutorial, we’ll create a custom full-screen loading spinner that appears when users submit a Gravity Forms form, providing better visual feedback during submission.
The Problem with the Default Spinner
By default, Gravity Forms displays a small spinner next to the submit button when a form is being processed. This subtle indicator can be easily missed, especially on larger screens or forms that require scrolling.
Our Solution
We’ll implement a full-screen transparent overlay with a centered SVG spinner that:
- Appears immediately when a form is submitted
- Covers the entire screen with a semi-transparent background
- Shows a smooth SVG animation in the centre
- Disappears once the form submission is complete
- Features smooth fade transitions
Implementation
The best part? You won’t need to modify any HTML structure. Our solution uses jQuery (which comes with WordPress) to create the overlay dynamically when needed.
Step 1: Create a Custom Plugin, Add to functions.php or Code Snippets Plugin
Create a new file called gravity-forms-fullscreen-spinner.php
in your /wp-content/plugins/
directory with this code (or add it to you functions.php or create a new code snippet in your Code Snippets plugin:
Step 2: Activate and Test
If you created a plugin, activate it through the WordPress admin panel. If you added the code to functions.php
, or a new code snipper you’re already set.
Visit a page with a Gravity Forms form and submit it. You should see a full-screen overlay with a centred spinning animation that fades in when you submit the form and fades out once the submission is complete.
How It Works
Our solution consists of three main components:
- The Overlay: A fixed-position div that covers the entire screen with a semi-transparent black background
- The Spinner: An SVG animation that indicates loading
- Event Handlers: JavaScript that shows and hides the overlay at the appropriate times
The Code Explained
- We create a new div element and append it to the body
- We add CSS styles to position the overlay and spinner
- We use jQuery to listen for form submission events
- We use Gravity Forms’ built-in events to know when to remove the overlay
- We use CSS transitions for smooth fade effects
Customisation Options
You can easily modify this solution to match your site’s design:
- Change the overlay background colour and opacity in the CSS
- Replace the SVG spinner with your own design
- Adjust the spinner size (currently set to 50px)
- Modify the transition speed (currently 0.3s)
Benefits
This improved loading indicator:
- Provides clearer visual feedback to users
- Prevents users from attempting to submit a form multiple times
- Creates a more professional user experience
- Works with all Gravity Forms without modifying their HTML structure
Conclusion
With just a few lines of code, you can significantly improve the user experience of your WordPress forms. This solution works with all Gravity Forms on your site and requires no HTML modifications or additional plugins.