To add a custom button hover effect in Divi 5, open the Button module’s Advanced › Custom CSS › Free-Form CSS and paste CSS that starts with the selector keyword. Divi swaps selector for that module, so the effect applies to this one button. Leave the module’s Use Custom Styles For Button option off, or Divi’s own button styles can override the effect.
Divi’s Button module handles colours, borders and simple hover changes on its own. Effects like a light sweeping across the button, a fill sliding in or a glowing animated border need a little CSS. This guide shows how to add them in Divi 5, with a Divi 4 method too.
Key takeaways
- Divi 5: paste CSS beginning with
selectorinto Advanced › Custom CSS › Free-Form CSS on the Button module. - Divi 4: add a CSS class to the module and paste the CSS into Divi › Theme Options › General › Custom CSS.
- Keep “Use Custom Styles For Button” off so Divi’s button styles don’t fight the effect.
- Run the effect on
:focus-visibletoo, and switch motion off for people who prefer reduced motion.
Which hover effects need CSS?
Divi’s built-in hover options change properties such as colour, border and shadow. Effects that use a pseudo-element, a sliding layer or a keyframe animation need custom CSS. These are the ones Refract’s button hover effects generator writes for Divi:
| Effect | What happens on hover |
|---|---|
| Shine sweep | A soft band of light slides across the button |
| Fill slide | A second colour slides in from one side |
| Animated gradient border | A gradient border rotates around the button |
| Glow pulse | A soft glow breathes around the edge |
| 3D press | The button presses down onto a hard shadow |
| Underline grow | A line grows under the label |
| Gradient shift | The background gradient slides across |
| Glass | A frosted, translucent button for use over images |
| Neon | A bright outline and glow |
| Lift | The button rises with a deeper shadow |
Add a hover effect in Divi 5
- Open the settings for the Button module.
- In the Design tab, check that Use Custom Styles For Button is off.
- Go to Advanced › Custom CSS and choose the Free-Form CSS tab.
- Paste the code and save the page.
This is the shine sweep as the generator writes it for Divi 5, shortened slightly here (the generator also sets the font size, weight and alignment):
selector.et_pb_button,
selector .et_pb_button {
position: relative;
overflow: hidden;
isolation: isolate;
background: #2f4bff;
color: #ffffff;
border: 0;
border-radius: 12px;
padding: 13px 24px;
}
selector.et_pb_button::before,
selector .et_pb_button::before {
content: "";
position: absolute;
inset: 0;
background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, .45) 50%, transparent 70%);
transform: translateX(-120%);
transition: transform 0.5s cubic-bezier(.2,.8,.2,1);
pointer-events: none;
}
selector.et_pb_button:hover::before,
selector .et_pb_button:hover::before,
selector.et_pb_button:focus-visible::before,
selector .et_pb_button:focus-visible::before {
transform: translateX(120%);
}
@media (prefers-reduced-motion: reduce) {
selector.et_pb_button::before,
selector .et_pb_button::before {
transition: none;
}
}
Each rule lists two selectors, selector.et_pb_button and selector .et_pb_button, so it reaches the clickable button whether Divi applies selector to the button itself or to the module around it. The shine uses ::before, which leaves Divi’s ::after button icon free to work as normal.
Divi’s help centre describes Free-Form CSS and the selector keyword in its guide to where to add custom CSS in Divi 5.
Add a hover effect in Divi 4
Divi 4’s module CSS boxes only accept declarations, not full rules with :hover and ::before, so for these effects use a class instead:
- Open the Button module and go to Advanced › CSS ID & Classes › CSS Class. Type
rf-button. - Paste the CSS into Divi › Theme Options › General › Custom CSS. The rules start with
.rf-button.et_pb_button. - Save, then exit the Visual Builder to check the effect on the live page.
Why isn’t the hover effect working?
| Problem | Fix |
|---|---|
| Divi’s own hover colour or border appears instead | Turn off Use Custom Styles For Button, or untick Include colours in the generator and set colours in Divi |
| Nothing changes in the Visual Builder | Save and view the live page; some effects only show outside the builder |
| The effect applies to every button | You pasted the Divi 4 CSS without adding the class, or used the class on several modules |
| The button icon has disappeared | Use an effect that draws on ::before, as the generator does for Divi |
| Old styles stay after changes | Clear Divi’s static CSS and your caching plugin, then hard refresh |
Keep the effect accessible
- Keyboard users never hover, so pair
:hoverwith:focus-visible. Every effect from the generator does this. - Reduced motion: some people get dizzy from movement. Wrap animations in a
prefers-reduced-motioncheck so they switch off when requested. - Touch screens have no hover, so the effect is a bonus. Make sure the button reads clearly as a button without it.
- Contrast: if the effect changes the background, check the label still passes on both colours with the contrast checker.
Tip: Effects that animate transform and opacity stay smooth because the browser can hand them to the graphics hardware. Avoid hover effects that animate width, height or padding, which force the page to re-lay out on every frame.
Make your own
Open the button hover effects generator, hover over the ten effects, then set your button colour, text colour, radius and speed. Choose Divi 5 or Divi 4 under Paste into and copy code written for the Button module, with the steps underneath. For a softer depth effect without movement, the box shadow generator builds layered shadows you can add on hover.


