Accordion / 029 — ニューモフィズム
デザイン見本
- Soft UI with Light & Shadow
- Elegant Button Integration
- Tactile & Realistic Feel
光と影のグラデーションだけで凹凸を表現するニューモフィズム(Neumorphism)を用いた、リアルでエレガントな感触のアコーディオンデザインです。
実装コード
HTML
<div class="container">
<div class="btn-box">
<button data-default-text="Neumorphic Soft UI" data-open-text="Close">Neumorphic Soft UI</button>
</div>
<div class="more">
<ul>
<li>Soft UI with Light & Shadow</li>
<li>Elegant Button Integration</li>
<li>Tactile & Realistic Feel</li>
</ul>
</div>
</div>
CSS
/* Note: 背景色と合わせるため、親要素のbody等の背景色を #e0e5ec に設定することをお勧めします */
.container {
margin-bottom: 0;
max-width: 100%;
background: #e0e5ec;
padding: 20px;
border-radius: 20px;
}
.container .btn-box button {
width: 100%;
padding: 18px 24px;
background: #e0e5ec;
border: none;
border-radius: 12px;
font-size: 15px;
font-weight: 600;
color: #6a7b8c;
cursor: pointer;
transition: all 0.3s ease;
text-align: left;
box-shadow: 7px 7px 15px rgba(163, 177, 198, 0.6), -7px -7px 15px rgba(255, 255, 255, 0.8);
position: relative;
}
.container .btn-box button::after {
content: '';
position: absolute;
right: 24px;
top: 50%;
width: 12px;
height: 12px;
border-right: 2px solid #6a7b8c;
border-bottom: 2px solid #6a7b8c;
transform: translateY(-70%) rotate(45deg);
transition: transform 0.3s ease;
}
.container:has(.more.appear) .btn-box button::after {
transform: translateY(-20%) rotate(-135deg);
}
.container .btn-box button:active {
box-shadow: inset 5px 5px 10px rgba(163, 177, 198, 0.6), inset -5px -5px 10px rgba(255, 255, 255, 0.8);
}
.container .more {
max-height: 0;
overflow: hidden;
transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
background: #e0e5ec;
border-radius: 12px;
margin-top: 0;
opacity: 0;
}
.container .more.appear {
max-height: 300px;
margin-top: 16px;
opacity: 1;
box-shadow: inset 5px 5px 10px rgba(163, 177, 198, 0.4), inset -5px -5px 10px rgba(255, 255, 255, 0.6);
}
.container .more ul {
list-style: none;
padding: 20px 24px;
margin: 0;
}
.container .more li {
padding: 10px 0;
color: #7a8b9c;
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
font-size: 14px;
position: relative;
}
.container .more li::after {
content: '';
position: absolute;
bottom: -1px; left: 0; right: 0;
height: 1px;
background: rgba(163, 177, 198, 0.3);
}
.container .more li:last-child,
.container .more li:last-child::after {
border-bottom: none;
background: transparent;
}
JS
(function () {
var container = document.querySelector('.container');
if (!container) return;
var button = container.querySelector('.btn-box button');
var content = container.querySelector('.more');
if (button && content) {
button.addEventListener('click', function() {
content.classList.toggle('appear');
if (content.classList.contains('appear')) {
this.textContent = this.dataset.openText || 'Close';
} else {
this.textContent = this.dataset.defaultText;
}
});
}
})();