Introduction to Neumorphic Designs
Tags: html, css
Published: 2022-09-23 14:35:09

by [Juboye Johnson](https://blog.openreplay.com/authors/juboye-johnson)

Nowadays, it's not enough for websites to have all of their capabilities running correctly; it's more fulfilling when people really enjoy the website's aesthetics. The smooth and flawless operation of all functionalities is a crucial concern for developers, but recently there has been a need to balance functionality and design.

[Neumorphism](https://hype4.academy/articles/design/neumorphism-in-user-interfaces), commonly referred to as soft UI or the advancement of [skeuomorphism](https://www.sketch.com/blog/2022/06/14/complete-guide-skeuomorphism/), employs CSS's box-shadow and highlights properties to provide the appearance that items are floating above the user interface.

In this article we will implement this type of design on a basic application like this:

![1](https://blog.openreplay.com/8c1c96de9506a83391f458478877fdfa/image01.gif)


## What is the Box-shadow property? 

A Box shadow is CSS giving an element a shadow; it doesn't get harder than that. You can throw a shadow from the frame of practically any element with the Box-shadow attribute. An element with a box shadow will have rounded corners if a [border-radius](https://www.w3schools.com/cssref/css3_pr_border-radius.asp) is added. 

We can apply numerous effects to any element's frame by separating values with commas. The Box shadow can be specified using blur, spread radius, X and Y offsets, and colors.

The syntax for Box-shadow looks like this `box-shadow: h-offset v-offset blur spread color |none|inset|initial`

- H-offset: This property is used to control the horizontal position of the shadow. It accepts two values: positive (+) and negative (-). Positive values (+) set the shadow on the right side of the box, while negative values (-) set the shadow on the left.
- V-offset: In this context, V stands for vertical, and it is used to specify the position of the value of the shadow vertically. The shadow above the box is set using the negative value, while the shadow below it is set using the positive value.
- Blur: This characteristic is optional, but it will be required for this article. Its sole purpose is to blur the box.
- Spread: This determines how large the shadow is.
- Color: This choice is entirely up to you. As its name suggests, it's used to give the shadow more hues if necessary.
- Inset: By utilizing this characteristic, we can create a shadow inside the box even though it is initially displayed outside it.
- Initial: Used to return the box-shadow property to its initial setting.

Neumorphism cannot exist without Box-shadow; therefore, instead of boring you with its attributes as is customary, let's focus on what Neumorphism is all about. Because the Box-shadow properties are the same as the Neumorphic properties, we are no longer required to discuss Neumorphism's properties.

## [Neumorphism](https://hype4.academy/articles/design/neumorphism-in-user-interfaces) vs [Skeuomorphism](https://www.sketch.com/blog/2022/06/14/complete-guide-skeuomorphism/) vs [flat design](https://www.hongkiat.com/blog/flat-design-resources/)

Many companies, including Apple, have adopted the neumorphic design trend. Although these designs borrow from skeuomorphism and flat design, they also diverge from them:

- Skeuomorphism design: these designs depict incredible three-dimensional features, enabling users to engage with the website or mobile app interfaces more naturally. A fantastic user experience is aided by it, and this was well-liked when iOS first came out.

Three-dimensional effects create the appearance of depth to an interface, which helps users connect certain pieces with distinctive designs and grasp interactive features in sites as we might have:

- Elements that appear elevated: display a message that can be clicked.

- Elements that appear unfilled: they look like they could be filled. 

These designs are frequently employed as technique signifiers for input elements like the search fields.

- Flat design: a user interface design style that uses simple, two-dimensional elements and bright colors. It is often mistaken for the skeuomorphic style that gives the illusion of three dimensions through copying real-life properties. It's common with landing pages, logos, and a lot more. Flat designs don't have any of these; reactionary movement against 3D, skeuomorphic, and realistic design styles.

![triple](https://blog.openreplay.com/static/99324699666d1f0ce27e689fe0d5e261/c6a49/triple.png)

## How to create a Neumorphic Design 

In this section, we'll utilize React and CSS to develop a simple app while implementing the Neumorphic design.

We must develop and import a Neumorphism component into our main "App.js" component because we will need one.

```javascript
//Neumorphism.Js

import React from 'react';
import "./styles.CSS";
  
function Neumorphism() {
    return (
        <main className='container'>
            <div className="shapes">
                    <p> Neumorphism effect</p>
                </div>
        </main>
    );
}
  
export default Neumorphism;


//App.Js
import React from 'react';
import "./styles.css";
import Neumorphism from './Neumorphism';
  
function App() {
    return (
        <div>
            <main>
                <Neumorphism />
            </main>
        </div>
    )
}
export default App;
```

![2](https://blog.openreplay.com/static/ff9d566254a79e04b050a3bf8f6b74f0/cb8a1/image02.png)

First, we will centralize whatever we are building and add a background color;

```
.container {
    height: 100Vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #e2e1e1;
}
```

![3](https://blog.openreplay.com/static/01689732e5cdf6597b6ed9795db02157/1cb32/image03.png)


We can take away the "Neumorphism effect" text. Now we will explore our Neumorphic designs in three shapes, rectangle, square, and circle. We need a `div` from our Neumorphism component as we will only use it for the shapes.

### Circle

You need a circle of any dimension; I used 150px for its size.

```
.circle {
    height: 150px;
    width: 150px;
    border: 1px solid rgba(94, 104, 121, 288);
    border-radius: 50%;
    padding: 2%;
}
```

![4](https://blog.openreplay.com/static/580547c4b20c8f36b0f26675b2a085f1/451dd/image04.png)

Adding the Box-shadow effect:

```
.circle {
    height: 150px;
    width: 150px;
    border-radius: 50%;
    padding: 2%;
    box-shadow: -4px -4px 10px #ffffff73, 2px 5px 5px rgba(94, 104, 121, 288);
}
```

![5](https://blog.openreplay.com/static/32db81466aaf51b1b6839b00feb9aa63/19c4c/image05.png)

Adding an inset:

```
.circle {
    height: 150px;
    width: 150px;
    border-radius: 50%;
    padding: 2%;
    box-shadow: -4px -4px 10px #ffffff73, inset 1px 3px 5px rgba(94, 104, 121, 288);
}
```

![6](https://blog.openreplay.com/static/741a3f1721458174709d4b8a304e409e/21aab/image06.png)


### Square 

This is easier to make; we just need to take off the border-radius property above, then we have a square:

```
.square {
    height: 150px;
    width: 150px;
    padding: 2%;
    box-shadow: -4px -4px 10px #ffffff73, 2px 5px 5px rgba(94, 104, 121, 288);
}
```

![7](https://blog.openreplay.com/static/300046590ceb5bad614f1b321a803a9b/b99b7/image07.png)

Let's include the inset:
 
```
.square {
    height: 150px;
    width: 150px;
    padding: 2%;
    box-shadow: -4px -4px 10px #ffffff73, inset 1px 3px 5px rgba(94, 104, 121, 288);
}
```

![8](https://blog.openreplay.com/static/6d90b71b9272e9b375761251ff2b36b9/4e17c/image08.png)


## Open Source Session Replay

_[OpenReplay](https://github.com/openreplay/openreplay) is an open-source, session replay suite that lets you see what users do on your web app, helping you troubleshoot issues faster. OpenReplay is self-hosted for full control over your data._

![replayer.png](https://static.openreplay.com/images/banner-blog.png)

_Start enjoying your debugging experience - [start using OpenReplay for free](https://github.com/openreplay/openreplay)._



## Neumorphic styling with colors

A good mix of Colors adds to the aesthetics of everything, and knowing the right colors to use on a web page guarantees a great UI. You can get a guide on colors to use with the neumorphic effect from [Neumorphis.io](https://neumorphism.io/#cb3434), and you can also go the extra mile by making the color of your shadows differ from your element's color.

```
  .container {
    height: 50Vh;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background-color: #e0e0e0;
    border: none;
    color: #3688db;
    box-shadow: inset 3px 3px 6px #9b9da3, inset -6px -6px 12px #ffaaff73;
    width: 20rem;
    margin-top: 150px;
}
```

This is what the style above gives us:

![9](https://blog.openreplay.com/static/9bc115e13759e1ac4bd6ed0bcc62673f/253ce/image09.png)


## Implementing Neumorphic Shadows in an App

We have explored this design in various shapes, colors, and animations; let's implement it in a simple project.

We will have ourselves build an increment app and improve its aesthetics with the Neumorphic shadows we learned already :

```javascript
//App.Js

import React, { useState } from 'react';
import './App.css';
  
function App() {
  const [count, setCount] = useState(0);

  function handleClick() {
    window.location.reload(false);
  }
  
  return (
    <div className="container">
      <div className="display">
        <h1>Open Replay</h1>
        <div className="display">
          {count}
        </div>
        <div>
          <button onClick={() => {
            setCount(count + 1)
          }} className="btn" >
            increment
          </button>
          <button onClick={() => {
            setCount(count - 1)
          }} className="btn" >
            decrement
          </button>
          <button onClick={handleClick} className="btn" >
            Refresh
          </button>
        </div>
      </div>
    </div>
  );
}
  
export default App;
```
 
The code above increments and decrements a number by 1; it's a straightforward app for this use case. We will add Neumorphic designs to the buttons and the `element` where the counting takes place.

```
.container {
    height: 100Vh;
    display: flex;
    align-items: center;
    justify-content: center;
    display: grid;
    background: #dee2f1;
}

.btn {
    padding: 1em 3em;
    border-radius: 10px;
    background-color: #e0e0e0;
    border: none;
    color: #3688db;
    font-weight: 700;
    letter-spacing: .2rem;
    text-align: center;
    outline: none;
    cursor: pointer;
    transition: .1s ease-in-out;
    box-shadow: inset 3px 3px 6px #9b9da3, inset -6px -6px 12px #ffaaff73;
}

button:hover {
    box-shadow: -2px -2px 6px rgba(255, 254, 55, .1), -2px -2px 4px rgba(255, 255, 255, .1), 2px 2px 2px rgba(255, 255, 255, .1), 2px 2px 4px rgba(0, 0, 0, .1);
}

button:active {
    box-shadow: inset -2px -2px 6px rgba(255, 255, 255, .1), inset -2px -2px 4px rgba(255, 255, 255, .1), inset 2px 2px 2px rgba(255, 255, 255, .1), inset 2px 2px 4px rgba(0, 0, 0, .1);
}

.display {
    border-radius: 10px;
    padding: 2%;
    box-shadow: inset 2px 2px 1px #9b9da3, inset -2px -2px 1px #ffaaff73;
    ;
    margin-bottom: 5%;
    color: #666666;
    font-weight: 700;
    text-align: center;
}
```

This is what it looks like:

![10](https://blog.openreplay.com/8c1c96de9506a83391f458478877fdfa/image10.gif)

## Conclusion

We concentrated on Neumorphism in this paper. We observed several forms to determine the distinctions between Neumorphism, Flat designs, and Skeuomorphism. The typical app user is a critic; therefore, this style of design keeps bad reviews at a distance.

> A TIP FROM THE EDITOR: You can learn more about shadows (very important in neumorphic designs) in our [Shadows in CSS](https://blog.openreplay.com/shadows-in-css) article.


[![newsletter](https://blog.openreplay.com/static/e6b18eda7a327511296a2f27692f9c70/e9957/newsletter.png)](https://newsletter.openreplay.com/)