WordPress / 8 MIN READ
Gravity Forms styling
Styling Gravity Forms with DIVI
From the original Fervor library. Examples may use older package versions.
Styling Gravity Forms with additional CSS or seeking alternative ways to tweak its appearance can truly elevate your forms from standard to spectacular, making them blend seamlessly with your site’s design. Here’s a guide to dressing up your forms in a tuxedo, or a ball gown, depending on your website’s theme!
Understanding the Basics of CSS Styling for Gravity Forms
Gravity Forms, out of the box, is quite the looker, but sometimes you want it to match your dance moves a bit more closely. That’s where custom CSS comes into play. Each element in Gravity Forms can be targeted with CSS for styling, from the overall form container down to the tiniest input field.
Identifying CSS Selectors
Before you start, you’ll need to know which elements to target. You can use your browser’s developer tools (right-click on the form element and select “Inspect” or “Inspect Element”) to find the CSS classes or IDs of the form elements you want to style.
Adding Custom CSS
Once you’ve identified the selectors, you can add your custom CSS in several places:
- WordPress Customizer: Go to Appearance > Customize > Additional CSS. This is a quick and easy way to add CSS that will be applied site-wide.
- Child Theme’s style.css File: If you’re using a child theme (and you should be, to preserve your changes when updating your theme), you can add your CSS directly to its
style.cssfile. - Gravity Forms Custom CSS: Some themes offer a place to add custom CSS directly to individual forms. Check your theme’s documentation to see if this is an option.
Sample CSS Snippets
Here are a few sample CSS snippets to get you started:
/* Style the form body */
body .gform_wrapper {
background-color: #f9f9f9;
padding: 20px;
border-radius: 10px;
}
/* Style all input fields */
.gform_wrapper input[type=text],
.gform_wrapper input[type=email],
.gform_wrapper textarea {
background-color: #FFF0F5;
border: 1px solid #D3D3D3;
padding: 10px;
border-radius: 5px;
}
/* Style the submit button */
.gform_wrapper .gform_footer input[type=submit] {
background-color: #4CAF50;
color: white;
padding: 15px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
/* Hover effect for the submit button */
.gform_wrapper .gform_footer input[type=submit]:hover {
background-color: #45a049;
}
Alternative Styling Options
- Gravity Forms Styler Plugins: There are several WordPress plugins designed specifically for styling Gravity Forms. These plugins often provide a user-friendly interface for designing your forms without having to write any code.
- Page Builder Widgets: Some WordPress page builders (like Divi, Elementor, and others) offer widgets or modules that integrate with Gravity Forms and may provide additional styling options through their interfaces.
- CSS Frameworks: If your site uses a CSS framework like Bootstrap or Foundation, you can apply these classes directly to your Gravity Forms elements to quickly style forms according to the framework’s guidelines.
Tips for Custom Styling
- Keep It Responsive: Make sure your custom styles don’t break the form’s responsiveness. Test on various devices to ensure your forms look great everywhere.
- Use !important Sparingly: Overusing
!importantcan make future styling changes difficult. Use it only when necessary to override styles. - Backup Before Changes: Always backup your site before adding custom code, just in case things don’t go as planned.
By following these guidelines and experimenting with CSS, you can create Gravity Forms that not only function well but also blend perfectly with your site’s aesthetic. Remember, the goal is to enhance the user experience while keeping your site’s design cohesive and visually appealing.
BONUS STYLING
Creating cool and unique styles for Gravity Forms can really set your forms apart and enhance the user experience on your site. Below are some stylish CSS snippets that you can add to your site to give your forms a fresh, modern look. Remember, you can add these snippets to your WordPress Customizer under Appearance > Customize > Additional CSS, or to your child theme’s style.css file.
1. Modern & Sleek Input Fields
This style gives your input fields a modern, sleek design with a subtle shadow to make them pop.
body .gform_wrapper form .gform_body .gform_fields .gfield input[type=text],
body .gform_wrapper form .gform_body .gform_fields .gfield textarea,
body .gform_wrapper form .gform_body .gform_fields .gfield select {
background-color: #ffffff;
border: 2px solid #eeeeee;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
padding: 10px 15px;
font-size: 16px;
border-radius: 4px;
transition: border-color 0.3s;
}
body .gform_wrapper form .gform_body .gform_fields .gfield input[type=text]:focus,
body .gform_wrapper form .gform_body .gform_fields .gfield textarea:focus,
body .gform_wrapper form .gform_body .gform_fields .gfield select:focus {
border-color: #4CAF50;
outline: none;
}
2. Button with Hover Effect
This snippet styles the submit button with a cool hover effect, making it more interactive and visually appealing.
body .gform_wrapper .gform_footer input[type=submit] {
background-color: #333333;
color: #ffffff;
padding: 12px 30px;
border: none;
border-radius: 30px;
transition: background-color 0.3s ease-in-out;
font-size: 16px;
cursor: pointer;
}
body .gform_wrapper .gform_footer input[type=submit]:hover {
background-color: #555555;
}
3. Stylish Error Messages
Make your error messages stand out with a stylish design that captures the user’s attention without being too jarring.
body .gform_wrapper .validation_error {
background-color: #ffdddd;
border-left: 4px solid #ff5566;
padding: 10px;
margin: 20px 0;
color: #333;
border-radius: 4px;
}
body .gform_wrapper li.gfield.gfield_error {
border-top: 2px solid #ff5566;
background-color: #ffdddd;
border-radius: 4px;
}
body .gform_wrapper li.gfield .gfield_description.validation_message {
color: #ff5566;
}
4. Floating Labels
Floating labels add a dynamic look to your form fields. This snippet requires a bit of additional setup, such as adding specific classes to your fields in the Gravity Forms editor to make the labels “float” when the field is focused or filled.
body .gform_wrapper .floating-labels .gfield_label {
position: absolute;
pointer-events: none;
left: 20px;
top: 10px;
transition: 0.2s ease all;
color: #999;
}
body .gform_wrapper .floating-labels .gfield input[type=text]:focus ~ .gfield_label,
body .gform_wrapper .floating-labels .gfield input[type=text]:valid ~ .gfield_label {
top: -20px;
font-size: 12px;
color: #5264AE;
}
For the floating labels to work, you would need to wrap your input and label in a div with a class of floating-labels and ensure your inputs are set to required or use JavaScript to add the :valid pseudo-class when the field is filled.
Customizing Your Forms
These snippets are just starting points. Feel free to adjust colors, sizes, and transitions to match your site’s theme. CSS allows you to creatively modify almost every aspect of your Gravity Forms, so don’t hesitate to experiment with different styles to create something unique for your website!
Bonus MORE STYLING
Absolutely, let’s add some more pizzazz to those labels and buttons on your Gravity Forms with a sprinkle of CSS magic. These styles will help your forms stand out and improve the user experience by making your forms not only more visually appealing but also more interactive.
Stylish Labels with Animation
This CSS snippet will give your labels a stylish look with a simple animation that makes them slide up when the input is focused or filled. It’s a neat effect that enhances the form’s interactivity.
/* Base styles for your form fields */
body .gform_wrapper .gfield input[type='text'],
body .gform_wrapper .gfield input[type='email'],
body .gform_wrapper .gfield input[type='number'],
body .gform_wrapper .gfield textarea {
position: relative;
z-index: 1;
padding: 25px 10px 10px 10px;
border: 2px solid #e2e2e2;
background-color: transparent;
transition: border-color 0.3s;
}
/* Animated label styles */
body .gform_wrapper .gfield label.gfield_label {
position: absolute;
z-index: 0;
top: 16px;
left: 10px;
transition: all 0.3s;
opacity: 0.7;
}
/* Slide up the label on input focus or when the field is not empty */
body .gform_wrapper .gfield input[type='text']:focus + label,
body .gform_wrapper .gfield input[type='text']:not(:placeholder-shown) + label,
body .gform_wrapper .gfield input[type='email']:focus + label,
body .gform_wrapper .gfield input[type='email']:not(:placeholder-shown) + label,
body .gform_wrapper .gfield input[type='number']:focus + label,
body .gform_wrapper .gfield input[type='number']:not(:placeholder-shown) + label,
body .gform_wrapper .gfield textarea:focus + label,
body .gform_wrapper .gfield textarea:not(:placeholder-shown) + label {
top: -10px;
opacity: 1;
font-size: 12px;
color: #5264AE;
}
/* Ensure the label stays on top when the field is focused */
body .gform_wrapper .gfield input:focus,
body .gform_wrapper .gfield textarea:focus {
border-color: #5264AE;
}
Cool Button Styling with Gradient and Shadow
Give your submit button a modern look with a gradient background and a subtle shadow for depth. This snippet also includes a hover effect to make the button feel dynamic.
/* Gradient and shadow for the submit button */
body .gform_wrapper .gform_footer input[type='submit'] {
background-image: linear-gradient(to right, #6a11cb 0%, #2575fc 100%);
color: white;
padding: 12px 30px;
border: none;
border-radius: 30px;
box-shadow: 0 4px 6px rgba(0,0,0,0.2);
transition: all 0.3s ease;
cursor: pointer;
font-weight: bold;
text-transform: uppercase;
}
/* Darken the gradient on hover */
body .gform_wrapper .gform_footer input[type='submit']:hover {
background-image: linear-gradient(to right, #5711cb 0%, #2575fc 100%);
box-shadow: 0 6px 8px rgba(0,0,0,0.3);
}
Tips for Advanced Customization
- Be Consistent: Ensure your form styles align with your overall website design for a cohesive look.
- Test Responsiveness: Always check how your forms look on different devices to ensure the styles are responsive and look good on mobile, tablets, and desktops.
- Use Custom Classes: For more control, you can assign custom CSS classes to individual fields, labels, or buttons directly in Gravity Forms and then style those classes as needed.
By integrating these stylish CSS tweaks, you’ll not only improve the aesthetics of your forms but also the usability, making form-filling a more engaging experience for your users. Remember, the key to great design is in the details, so don’t be afraid to experiment with different styles to find what works best for your site!