← 一覧へ

Accordion / 025 — 左線アクセント|Left Border Accent

デザイン見本

  • Clean and modern minimal design
  • Focus on typography and whitespace
  • Left border indicates active state

左側の太いボーダーラインがアクセントとなるモダンなデザイン。 展開時にボーダーの色が濃くなり、視線誘導を助けます。 コンテンツ部分も左線がつながることで一体感を演出しています。

実装コード

HTML
<div class="container">
    <div class="btn-box">
        <button data-default-text="Left Border Accent" data-open-text="Close">Left Border Accent</button>
    </div>
    <div class="more">
        <ul>
            <li>Clean and modern minimal design</li>
            <li>Focus on typography and whitespace</li>
            <li>Left border indicates active state</li>
        </ul>
    </div>
</div>
CSS
/* アニメーション定義 */
@keyframes acc25-slideIn {
    0% {
        opacity: 0;
        transform: translateX(-10px);
    }
    100% {
        opacity: 1;
        transform: none;
    }
}

.container {
    width: 100%;
}

.container .btn-box button {
    width: 100%;
    padding: 18px 24px;
    background: #f8f9fa;
    border: none;
    border-left: 4px solid transparent;
    font-size: 15px;
    font-weight: 600;
    color: #444;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    position: relative;
}

.container .btn-box button:hover {
    background: #f1f3f5;
    color: #222;
}

.container .btn-box button.active {
    background: #fff;
    border-left-color: #333;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    color: #000;
}

.container .more {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    background: #fff;
    border-left: 4px solid #f1f3f5;
}

.container .more.appear {
    max-height: 200px;
    border-left-color: #333;
}

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

.container .more li {
    padding: 8px 0;
    color: #666;
    font-size: 14px;
    animation: acc25-slideIn 0.4s ease forwards;
    opacity: 0;
}

/* Staggered animation */
.container .more.appear li:nth-child(1) { animation-delay: 0.1s; }
.container .more.appear li:nth-child(2) { animation-delay: 0.2s; }
.container .more.appear li:nth-child(3) { animation-delay: 0.3s; }
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');
                this.classList.toggle('active'); // ボタンにもクラス付与
                
                // ボタンテキストの切り替え
                if (content.classList.contains('appear')) {
                    this.textContent = this.dataset.openText || 'Close';
                } else {
                    this.textContent = this.dataset.defaultText;
                }
            });
        }
    });
});