Home >Web Front-end >CSS Tutorial >Neumorphism: What It Is and CSS Examples
In recent years, UI design has seen the emergence of various trends, one of which is Neumorphism. This design trend combines soft, inset styles with a modern aesthetic, creating an illusion of depth and layering. In this post, we will explore the principles of Neumorphism, its benefits and drawbacks, and provide practical examples with CSS code snippets to help you implement this trendy design in your own projects.
Neumorphism, short for "new skeuomorphism", is a design approach that uses soft shadows and highlights to create a three-dimensional appearance. Unlike the traditional skeuomorphic design, which mimics real-world objects, Neumorphism aims for a more subtle, modern feel. It relies heavily on light and shadow to create a sense of depth, often employing a monochromatic color palette.
Let’s dive into some practical CSS examples to help you create Neumorphic UI components.
<button class="neumorphic-button">Click Me</button>
body { background-color: #e0e0e0; /* Light background */ display: flex; justify-content: center; align-items: center; height: 100vh; } .neumorphic-button { padding: 15px 30px; border-radius: 12px; border: none; background: #e0e0e0; /* Same as body color */ box-shadow: 8px 8px 15px #a3b1c6, -8px -8px 15px #ffffff; /* Soft shadows */ font-size: 16px; cursor: pointer; transition: all 0.3s ease; } .neumorphic-button:hover { box-shadow: 4px 4px 10px #a3b1c6, -4px -4px 10px #ffffff; /* Change shadows on hover */ }
<div class="neumorphic-card"> <h2>Neumorphic Card</h2> <p>This is an example of a neumorphic card.</p> </div>
body { background-color: #e0e0e0; /* Light background */ display: flex; justify-content: center; align-items: center; height: 100vh; } .neumorphic-card { padding: 20px; border-radius: 15px; background: #e0e0e0; box-shadow: 10px 10px 20px #a3b1c6, -10px -10px 20px #ffffff; /* Neumorphic shadows */ width: 300px; text-align: center; transition: all 0.3s ease; } .neumorphic-card:hover { box-shadow: 5px 5px 15px #a3b1c6, -5px -5px 15px #ffffff; /* Lighter shadows on hover */ }
<input type="text" class="neumorphic-input" placeholder="Type something...">
body { background-color: #e0e0e0; /* Light background */ display: flex; justify-content: center; align-items: center; height: 100vh; } .neumorphic-input { padding: 10px; border-radius: 10px; border: none; background: #e0e0e0; box-shadow: inset 6px 6px 10px #a3b1c6, inset -6px -6px 10px #ffffff; /* Inner shadows for depth */ width: 300px; transition: all 0.3s ease; } .neumorphic-input:focus { box-shadow: inset 4px 4px 8px #a3b1c6, inset -4px -4px 8px #ffffff; /* Adjust shadows on focus */ }
<div class="neumorphic-toggle"> <input type="checkbox" id="toggle" /> <label for="toggle">Toggle</label> </div>
body { background-color: #e0e0e0; /* Light background */ display: flex; justify-content: center; align-items: center; height: 100vh; } .neumorphic-toggle { display: flex; align-items: center; cursor: pointer; } .neumorphic-toggle input { display: none; /* Hide the checkbox */ } .neumorphic-toggle label { padding: 10px; border-radius: 20px; background: #e0e0e0; box-shadow: 6px 6px 12px #a3b1c6, -6px -6px 12px #ffffff; position: relative; transition: all 0.3s ease; } .neumorphic-toggle input:checked + label { box-shadow: inset 6px 6px 12px #a3b1c6, inset -6px -6px 12px #ffffff; background: #d1d1d1; }
A design tool that allows you to create neumorphic designs and export them as CSS:
Visit Neumorphism.io
Neumorphism is a captivating design trend that offers a fresh perspective on UI design, emphasizing depth and interactivity. While it has its advantages, including aesthetic appeal and user engagement, designers must also be cautious of its accessibility and usability challenges. By implementing the CSS examples provided, you can start creating Neumorphic interfaces that are not only modern and visually appealing but also functional and user-friendly.
As with any design trend, always consider the target audience and ensure that your interface remains accessible to all users. Happy designing!
The above is the detailed content of Neumorphism: What It Is and CSS Examples. For more information, please follow other related articles on the PHP Chinese website!