Divi Text Module Gradient with Gradient Shadow

Easy

CSS

Details

In this Divi Code Snippet, we will target the Divi Button Module to add a colorful gradient fill on the text, as well as an awesome gradient shadow. I discovered this method using Tailwind CSS on a reddit post, and figured I would adapt it to work with the Divi Button module.

You can add the CSS in either a code module, Divi Theme Options, or the style.css of your Divi Child Theme. Once that is done, just make sure to wrap your text in a span tag using the code below. You might have to play with the transform: translateY(-15%); to get the shadow in the right spot.

If you want an animated version of this snippet, please check out our post on a Divi Text Module with Animated Shadow Gradient.

Snippets Demo

Divi Gradient Text Shadow Code Snippet

Code

1

Description:
This code will use a mask to give your text a gradient fill.

Language: CSS

Where to add: Divi Theme Options

                        .de-text-gradient {
    position: relative;
    display: inline; /* or 'inline-block' depending on layout needs */
    background-image: linear-gradient(to right, #f687b3, #7f9cf5, #48bb78);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
                    
2

Description:
This CSS adds a pseudo element that create the blur effect with the same gradient as the text.

Language: CSS

Where to add: Divi Theme Options

                        .de-text-gradient::before {
    content: attr(data-text); /* duplicate the text */
    position: absolute;
    top: 50%; /* centers vertically */
    left: 0;
    right: 0;
    transform: translateY(-15%); /* ensures perfect vertical centering */
    z-index: -1; /* places the shadow behind the text */
    background-image: inherit; /* uses the same gradient as the parent */
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: blur(15px); /* adjust blur intensity as needed */
    width: 100%; /* ensures the blurred text has the same width as the original text */
    height: 100%; /* ensures the blurred text has the same height as the original text */
    display: inline; /* or 'inline-block' */
    font-size: inherit; /* ensures the blurred text is the same size as the original text */
    line-height: inherit; /* keeps the line height the same */
    text-align: center; /* centers the text horizontally */
}
                    
3

Description:
You need to wrap your text in the Divi Text modules in a span with a data-text element which is what is used to duplicate the text for the pseudo element.

Language: CSS

Where to add: functions.php

                        <span class="de-text-gradient" data-text="Animated Gradient">Animated Gradient</span>
                    

Related Snippets

Explore more from Divi Engine