Description
The filter gform_disable_css
can be used to disable all CSS files from being loaded on the frontend. This covers styles responsible for handling conditional logic, column structures, hidden fields, CSS Ready Classes, and other form elements.
Note: Using this filter to disable CSS output will prevent Conversational Forms from functioning properly.
Note: Using this filter can create accessibility issues. For more information on ensuring your form remains accessible, refer to our Accessibility Guide for Content Providers and Accessibility Checklist for Gravity Forms articles.
Incompatibilities
Some fields and form settings won’t work as expected when the filter is enabled:
- The honeypot anti-spam field, normally hidden from users, will be shown on the front end.
- The Datepicker field can lose its default styling.
- CSS Ready Classes may not work as intended, breaking the intended form structure or layout.
- Hidden fields and fields with Visibility set to hidden may appear on the front end.
- Multi-paged forms might not work as expected.
- Conditional Logic might not work as expected.
- Fields with the enhanced UI enabled won’t work as expected.
Usage
add_filter( 'gform_disable_css', 'your_function_name' );
Parameters
- $is_css_disabled bool
Indicates if CSS files are to be loaded by Gravity Forms. Default is false.
Example
Disable loading of CSS files
This example would disable all loading of CSS files for all forms.
add_filter( 'gform_disable_css', '__return_true' );
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Since
This filter was added in Gravity Forms v2.8.
Source Code
This filter is located in form_display.php and includes/blocks/class-gf-block-form.php and
includes/form-display/class-gf-form-display-service-provider.php and
includes/system-status/class-gf-system-report.php.