HG WEB STUDIO

Filed in: ,

Easy CSS Neumorphism Button With Click Effects

Updated on: June 14, 2024

Table of Contents

In this post, I’ll walk you through how to create a neumorphism button with click effects so you can easily add it to your web designs and Elementor.

Neumorphism combines minimalism with soft 3D shadows and highlights to create a polished and clean look in web designs.

This button is perfect for modern and minimal web designs that prioritize clean and sleek aesthetics. I used Nunito Sans, a Google font included in the Elementor plugin. Some other fonts that would work well with this button include Roboto, Oxygen, and Source Sans Pro.

25 Best Font Combinations for Elementor Websites svg of arrow pointing right

CSS Neumorphism Button Demo

See the Pen Neumorphism Clicky Button by Kate (@kate_hg123) on CodePen.

HTML Breakdown

I used the <a> element for this button, but you can swap it out for the <button> element. Each of these elements has different use cases.

Use Cases:

  • Use the button element when: You need a clickable element to trigger an action, like submitting a form, triggering JavaScript functions, or performing an action within the webpage.
  • Use the anchor element when: You need to create hyperlinks for navigation, whether it’s within the same webpage or linking to external pages.

HTML Code using the anchor element

<a href="#" class="custom-btn" role="link">Click Me</a>

To create a link that is visually styled as a button, we need to have the following attributes: href, class, and role.

  • href: Defines the destination link. Replace the ‘#’ with your link or anchor.
  • class: Defines the selector to target for styling.
  • role: Defines the purpose of the element for accessibility technologies like screen readers.

Learn more about links at W3Schools.

HTML Code using the button element

<button id="my-btn" class="custom-btn" type="button">Submit</button>

To create a button, we need to have the following attributes: class, id, and type.

  • class: Defines the selector to target for styling.
  • id: Defines the selector to target for JavaScript functions or other element-specific styling and actions. Ids are more specific than classes and should only be used once, whereas classes can be used for multiple elements.
  • type: Defines the type of button and its intended action. There are three types: button, submit, and reset.

Learn more about buttons at W3Schools.

CSS Breakdown

To style our button, we need to target the element with the class selector we chose in the HTML. I’m using ‘.custom-btn’.

First, let’s create its normal state. The background should be transparent to match the background of your web page. To make the button stand out on the page, we add box-shadow effects with a highlight on the top left and a shadow on the bottom right. The cubic-bezier transition creates the bouncy click effects. If you prefer a normal click effect, change the cubic-bezier property to ease or linear.

To maintain the soft design, be sure to have highlight and shadow colors similar to the background color. In this example, the background is lavender, so the highlight is light lavender and the shadow is dark lavender.

Three circles representing the highlight color, background color, and shadow color of the neumorphism button.
/* button in its normal state */
.custom-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 60px;
  background-color: transparent;
  color: #222;
  text-decoration: none;
  font-family: "Nunito Sans", sans-serif;
  font-size: 24px;
  letter-spacing: 2px;
  border-radius: 30px;
  border: none;
  box-shadow: 12px 12px 16px 0 #c6bacf, -12px -12px 16px 0 #f2ebfc, inset 0 0 0 0 transparent;
  transition: box-shadow 200ms, transform 300ms cubic-bezier(.2,2,1,1);
}

Next, let’s create a hover effect. On hover, the text color changes.

/* hover effect */
.custom-btn:hover {
  color: #434245;
}

Lastly, we need an active state to create a visual indication that the button was clicked. The box-shadow changes from outside the button to inside the button. This creates the illusion that the button was pushed in.

The shadow colors remain the same as before but they are displayed in the rgba() format to include transparency.

/* button active state */

.custom-btn:active {
  box-shadow: 0 0 0 transparent, 0 0 0 transparent, inset 8px 8px 12px 0px rgba(198, 186, 207, .9), inset -8px -8px 12px 0px rgba(242, 235, 252, 0.9);
  transform: scale(.9);
}

How to add the Neumorphism button in Elementor

To create this button in Elementor, I’m using the button widget instead of writing my own HTML code. We can write fewer lines of custom CSS by using some of the style settings available in the widget.

For this example, I’ve adjusted some of the properties to fit the styling of the web design, like the border radius, background color, and font. The background color of the button widget needs to be transparent.

Step 1: Add the button widget to your canvas and give it some basic styling

Navigate to the button widget content tab:

  1. Change the CTA text
  2. Add the button link

Then, in the button widget style tab:

  1. Change the typography to match your website (font family, font size, weight, etc.).
  2. Choose the text color. I’m using #222.
  3. Change the text hover color to #434245.
  4. Change the background color to transparent.
  5. Set the border type to none.
  6. Set the border-radius to 30px.
  7. Add padding to increase the size of your button. I used 24px for top and bottom and 48px for left and right.

Lastly, in the button widget advanced tab:

  1. In the CSS classes box, type in your class selector. I used ‘custom-btn’.

Now let’s write our code.

Step 2: Write the custom CSS in the WordPress Customizer

You can also use the custom CSS area in the advanced tab of the button widget. I prefer keeping all my custom code in one place for better management.

WordPress customizer showing CSS code for neumorphism button in Elementor

In the WP customizer navigate to ‘Additional CSS’

1. Create the normal state (how it looks on the page without any user interaction)

  • Set the selector: .custom-btn {}.
  • Inside the curly brackets, set the following properties: border-radius, box-shadow, transition, and z-index.
/* button in its normal state */ 
.custom-btn {
  border-radius: 30px;
  box-shadow: 12px 12px 16px 0 #cbc2d1, -12px -12px 16px 0 #fdf7ff, inset 0 0 0 0 transparent;
  transition: box-shadow 200ms, transform 300ms cubic-bezier(.2,2,1,1);
  z-index: 1;
}

2. Next, create the active state for button.

  • Set the selector .custom-btn with :active {}.
  • Inside the curly brackets, set the following properties: box-shadow and transform.
/* button in active state */
.custom-btn:active {
  box-shadow: 0 0 0 transparent, 0 0 0 transparent, inset 8px 8px 12px 0px rgba(203, 194, 209, .9), inset -8px -8px 12px 0px rgba(253, 247, 255, 0.9);
  transform: scale(.9);
}

Publish your changes.

Step 3: Checking for mobile responsiveness in Elementor

Lastly, we need to check our code for mobile responsiveness.

In the Elementor editor, adjust the padding or width of your button for tablet and mobile view using Elementor’s responsive settings.

Final Thoughts

Feel free to use my code as is, or play around with the different properties to create a button that fits your website aesthetic. Experiment with the colors and font, and make it yours!

Remember, if you experience any issues or have questions along the way, feel free to drop them in the comments below. I’d love to see your work, and I’m here to help!

Full Code for Neumorphism Button with CSS Effects in Elementor

/* button in its normal state */ 
.custom-btn {
  border-radius: 30px;
  box-shadow: 12px 12px 16px 0 #cbc2d1, -12px -12px 16px 0 #fdf7ff, inset 0 0 0 0 transparent;
  transition: box-shadow 200ms, transform 300ms cubic-bezier(.2,2,1,1);
  z-index: 1;
}

/* button in its active state */
.custom-btn:active {
  box-shadow: 0 0 0 transparent, 0 0 0 transparent, inset 8px 8px 12px 0px rgba(203, 194, 209, .9), inset -8px -8px 12px 0px rgba(253, 247, 255, 0.9);
  transform: scale(.9);
}

Table of Contents

Search

Browse by Category

Leave a Reply

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