← 一覧へ

Accordion / 019 — シンプルグレー|Simple Gray

デザイン見本

  • Grayed out simple design
  • Clean and minimal appearance
  • Subtle hover effects

主張しすぎないグレー配色のシンプルデザイン。 補助的な情報や、目立たせたくない補足情報の表示に適しています。

実装コード

HTML
<div class="container">
    <div class="btn-box">
        <button data-default-text="Simple Gray Accordion" data-open-text="Close">Simple Gray Accordion</button>
    </div>
    <div class="more">
        <ul>
            <li>Grayed out simple design</li>
            <li>Clean and minimal appearance</li>
            <li>Subtle hover effects</li>
        </ul>
    </div>
</div>
CSS
/* アニメーション定義 */
@keyframes acc19-fadeIn {
    0% {
        opacity: 0;
        transform: translateY(-5px)
    }
    100% {
        opacity: 1;
        transform: translateY(0)
    }
}

.container {
    width: 100%;
}

.container .btn-box button {
    width: 100%;
    padding: 13px 16px;
    background: #eeeeee;
    border: none;
    font-size: 14px;
    font-weight: 400;
    color: #333;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
    position: relative;
}

.container .btn-box button::after {
    content: '▼';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: #999;
    transition: transform 0.3s;
}

.container .more {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    background: transparent;
}

.container .more.appear {
    max-height: 200px;
    animation: acc19-fadeIn 0.3s ease;
}

.container:has(.more.appear) .btn-box button::after {
    transform: translateY(-50%) rotate(180deg);
    color: #666;
}

.container .more ul {
    list-style: none;
    padding: 10px 16px;
    margin: 0;
}

.container .more li {
    padding: 6px 0;
    color: #999;
    font-size: 13px;
}
JS
document.addEventListener("DOMContentLoaded", () => {
    document.querySelectorAll('.container').forEach(container => {
        const button = container.querySelector('.btn-box button');
        const 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;
                }
            });
        }
    });
});