Create a Divi Button with no Text

Written by Dan Mossop

The Divi theme comes with a Button module which lets you create buttons with text and an optional icon. But what if you just want the icon, but no text. Here's a couple of ways to achieve that.

To create an icon-only button in Divi:

  1. Use PHP code to allow display of buttons without text.
  2. In Button Module, clear text and configure icon to show.
  3. Adjust padding and custom CSS for styling.

Alternatively, use the Icon Module for a simple solution with flexible styling and link options.

Create an Icon-only Button using the Button Module

By default, Divi won't display an button which has no text, or whose text is just blank spaces .

To create a button with an icon, but no text:

1. Add the following PHP code to allow buttons with no text to be displayed anyway:

add_filter('et_pb_module_shortcode_attributes', 'dbcAllowEmptyButtonText', 10, 3);

function dbcAllowEmptyButtonText($props, $atts, $render_slug) {
	if ($render_slug !== 'et_pb_button') return $props;
	if (!is_array($props)) return $props;
	if (!empty($props['button_text'])) return $props; 
	$props['button_text'] = ' '; 
	return $props;
}

2. Add a button with an empty text field, like so:

3. Configure the button icon to show at all times. To do so, set:

  • Button Settings > Design > Button > Use Custom Styles for Button = Yes
  • Button Settings > Design > Button > Show Button Icon = Yes
  • Button Settings > Design > Button > Only Show Icon On Hover for Button = No

4. Select your icon, at:

Button Settings > Design > Button > Button Icon

5. Equalize the padding round the icon by setting the left and right padding to 16px, at:

Button Settings > Design > Spacing > Padding 

6. Make some final adjustments in the icon's custom CSS, by setting:

Button Settings > Advanced > Custom CSS > After

To:

margin-left: 0 !important;
position: relative;

Like so:

7. Save and view the page on the front-end and you should see the result:

Notes:

  • The button may not show properly in visual builder / may prove easier to edit using Divi's wireframe mode.
  • Here's a post from Elegant Themes that achieves a similar result in a different way – by changing the text of the button to itself be the icon.

Create an Icon-only Button using the Divi Icon Module

If what you're looking for is an icon without any accompanying text, the Divi Icon Module offers a straightforward approach to achieving this. While the above method works well, particularly if you have existing styles or functional needs for a button, for a new button the icon module can be a great choice.

Here's how you can use the Divi Icon Module to create an elegant icon-only button:

  1. Add a new Icon Module to your layout wherever you need the icon button.
  2. Select your desired icon from the Icon Module Settings > Content > Icon.
  3. If needed, apply your custom styles such as color, size, and hover effects within Icon Module Settings > Design.
  4. To ensure your icon is clickable like a button, add a link to the module at Icon Module Settings > Content > Link.
  5. To further emulate button-like padding around your icon, adjust padding settings within Icon Module Settings > Design > Spacing.

The Divi Icon Module is simple and flexible, allowing you to easily add icons that serve as buttons without any text clutter. It also provides the added benefit of being light on code and simple to update or edit.

If you'd like learn more about turning the icon module into a button, Elegant Themes a have a detailed tutorial on How to Design Icon Buttons with Divi’s Icon Module.

While both methods have their place, choosing between them can depend on your specific needs and circumstances. Thanks, Joe, for pointing out this efficient alternative!

Run PHP Code Directly in your Divi Layouts

Unlock endless customization, automation, and dynamic functionality by seamlessly adding PHP code to your Divi pages and posts with the Divi PHP Code Module. Style, preview, and debug your PHP creations directly in the visual builder with robust error handling and enhanced security.

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

4 Comments

    • Hey Joe, using an icon module is a great way to achieve a similar effect. I don't quite remember what motivated this post originally, but the method above could come in handy if you've got some existing button-specific styles / functionality in place. Thanks for sharing!

      Reply
    • Hey Pieter, it looks like a couple of changes are needed to get this to work correctly in the latest version of Divi (setting the icon position to relative and setting padding on the button). I've updated the post to break the steps down in more detail and include these changes. I hope it helps, but let me know if not. Thanks!

      Reply

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.

We may earn a commission when you visit links on our website.

Latest Posts

Change Divi Gallery Module Slider Arrow Size

Adjusting the size of slider arrows in the Divi Gallery module can help improve site navigation, enhance visual consistency, or better match your site’s design preferences. Whether you want to make navigation elements more prominent or integrate them seamlessly with...

Change Divi Gallery Module Slider Arrow Color

Customizing the appearance of your Divi Gallery module can enhance both the aesthetics and usability of your site. Changing the slider arrow color in the Gallery module slider layout allows you to ensure the navigation controls are clearly visible and match your...

Change Slider Arrow Icons in the Divi Gallery Module Slider Layout

Customizing the slider arrows in the Divi Gallery module slider layout allows you to enhance the visual appeal and user experience of your image galleries by aligning navigation icons with your website’s design style. This can help make galleries more intuitive and...

Set a Custom Start Value in Divi Number Counter Modules

Adjusting the starting value for Number Counter modules in Divi enables you to create more dynamic and tailored animations, such as counters that begin at a specific number rather than the default zero. This can enhance the presentation of statistics or milestones on...

Random Posts