Button Library · 3D
Neumorphic
Moulded from the surface behind it.
Works only when the page behind has the same colour as Background.
States
Default
Hover
Active
Focus
Code
3d-neumorphic.html
<button class="btn-3d-neumorphic" type="button"> <span>Get started</span> </button>
3d-neumorphic.css
.btn-3d-neumorphic {
--btn-bg: #e4e4ea;
--btn-fg: #4a4a5a;
--btn-font: inherit;
--btn-size: 15px;
--btn-weight: 600;
--btn-px: 22px;
--btn-py: 11px;
--btn-w: auto;
--btn-h: auto;
--btn-bw: 0px;
--btn-line: #8b6cff;
--btn-radius: 14px;
--btn-speed: 180ms;
}
.btn-3d-neumorphic {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5em;
box-sizing: border-box;
width: var(--btn-w);
height: var(--btn-h);
padding: var(--btn-py) var(--btn-px);
font-family: var(--btn-font);
font-size: var(--btn-size);
font-weight: var(--btn-weight);
line-height: 1.2;
color: var(--btn-fg);
background: var(--btn-bg);
border: var(--btn-bw) solid var(--btn-line);
border-radius: var(--btn-radius);
box-shadow: 6px 6px 12px color-mix(in srgb, var(--btn-bg) 82%, #000), -6px -6px 12px color-mix(in srgb, var(--btn-bg) 30%, #fff);
cursor: pointer;
text-decoration: none;
white-space: nowrap;
transition: all var(--btn-speed) ease;
}
.btn-3d-neumorphic:focus-visible {
outline: 2px solid var(--btn-bg);
outline-offset: 2px;
}
.btn-3d-neumorphic:disabled {
opacity: 0.5;
pointer-events: none;
}
.btn-3d-neumorphic__icon {
width: 1.15em;
height: 1.15em;
flex-shrink: 0;
}
.btn-3d-neumorphic:active {
box-shadow: inset 4px 4px 8px color-mix(in srgb, var(--btn-bg) 82%, #000), inset -4px -4px 8px color-mix(in srgb, var(--btn-bg) 30%, #fff);
}
@media (prefers-reduced-motion: reduce) {
.btn-3d-neumorphic {
animation: none !important;
transition: none !important;
}
}
3d-neumorphic.js
// No JavaScript needed: this one is CSS only.
3d-neumorphic.tsx
import type React from "react";
import "./3d-neumorphic.css"; // the CSS tab
export function Btn3dNeumorphic({ children = "Get started", ...props }: React.ComponentProps<"button">) {
return (
<button className="btn-3d-neumorphic" type="button" {...props}>
<span>{children}</span>
</button>
);
}
3d-neumorphic.html
<button class="relative inline-flex items-center justify-center gap-[0.5em] [box-sizing:border-box] [padding:11px_22px] [font-family:inherit] text-[15px] font-[600] [line-height:1.2] text-[#4a4a5a] bg-[#e4e4ea] [border:0px_solid_#8b6cff] rounded-[14px] [box-shadow:6px_6px_12px_color-mix(in_srgb,_#e4e4ea_82%,_#000),_-6px_-6px_12px_color-mix(in_srgb,_#e4e4ea_30%,_#fff)] cursor-pointer no-underline whitespace-nowrap [transition:all_180ms_ease] focus-visible:[outline:2px_solid_#e4e4ea] focus-visible:[outline-offset:2px] disabled:[opacity:0.5] disabled:[pointer-events:none] active:[box-shadow:inset_4px_4px_8px_color-mix(in_srgb,_#e4e4ea_82%,_#000),_inset_-4px_-4px_8px_color-mix(in_srgb,_#e4e4ea_30%,_#fff)] motion-reduce:[transition:none!important]" type="button"> <span>Get started</span> </button>