アコーディオンのデザイン7選|コピペで実装できるコード付き
レスポンシブ対応の実装例&コード付き!異なるデザインパターンのアコーディオンUIを集めました!
JavaScriptは共通なので、以下よりご利用ください。
JavaScript コードはこちら(全デザイン共通)
document.addEventListener('DOMContentLoaded', function() {
const accordionButtons = document.querySelectorAll('.btn-box button');
accordionButtons.forEach(button => {
button.addEventListener('click', function() {
const container = this.closest('[class^="container-"]');
const more = container.querySelector('.more');
const isOpen = more.classList.contains('appear');
more.classList.toggle('appear');
// ボタンテキストの変更(不要な場合は削除)
if (this.dataset.defaultText) {
if (isOpen) {
this.textContent = this.dataset.defaultText;
} else {
this.textContent = this.dataset.openText || '閉じる';
}
}
});
});
});
アコーディオンとは?
アコーディオンは、クリックやタップでコンテンツの開閉を切り替えるUIです。縦に並んだ項目を省スペースで表示でき、FAQやメニューなどによく使われます。
アコーディオンUIの実装方法を詳しく知りたい方はこちら
【JS】「もっと見る」ボタンの実装方法(アコーディオン)
クリックすることで、ニュース記事やブログなどの一覧を表示してくれるボタンの実装方法を紹介します。(アコーディオンUIと呼ばれます。) 情報量が多いために普段は隠…
目次
【1】シンプルアコーディオン
- シンプルで使いやすいデザイン
- 基本的な開閉アニメーション
- レスポンシブ対応
- 軽量で高速
- カスタマイズしやすい
<div class="container-1">
<div class="btn-box">
<button data-default-text="シンプルアコーディオン" data-open-text="閉じる">シンプルアコーディオン</button>
</div>
<div class="more">
<ul>
<li>シンプルで使いやすいデザイン</li>
<li>基本的な開閉アニメーション</li>
<li>レスポンシブ対応</li>
<li>軽量で高速</li>
<li>カスタマイズしやすい</li>
</ul>
</div>
</div>
@keyframes fadeIn {
0% {
opacity: 0;
transform: translateY(-10px);
}
100% {
opacity: 1;
transform: none;
}
}
.container-1 .btn-box button {
width: 100%;
padding: 15px 20px;
background: #fff;
border: 2px solid #e0e0e0;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
color: #333;
cursor: pointer;
transition: all 0.3s ease;
text-align: left;
}
.container-1 .btn-box button:hover {
background: #f8f9fa;
border-color: #007bff;
}
.container-1 .more {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease;
background: #fff;
border: 2px solid #e0e0e0;
border-top: none;
border-radius: 0 0 8px 8px;
}
.container-1 .more.appear {
max-height: 300px;
animation: fadeIn 0.3s ease;
}
.container-1 .more ul {
list-style: none;
padding: 20px;
margin: 0;
}
.container-1 .more li {
padding: 8px 0;
border-bottom: 1px solid #f0f0f0;
color: #555;
}
.container-1 .more li:last-child {
border-bottom: none;
}
/* レスポンシブ対応 */
@media (max-width: 768px) {
.container-1 .btn-box button {
font-size: 14px;
padding: 15px 20px;
}
.container-1 .more ul {
padding: 15px;
}
}
【2】カード風アコーディオン
- カードのような見た目
- 影付きで立体感を演出
- ホバーエフェクト付き
- スムーズな開閉アニメーション
- モダンなデザイン
<div class="container-2">
<div class="btn-box">
<button data-default-text="カード風アコーディオン" data-open-text="閉じる">カード風アコーディオン</button>
</div>
<div class="more">
<ul>
<li>カードのような見た目</li>
<li>影付きで立体感を演出</li>
<li>ホバーエフェクト付き</li>
<li>スムーズな開閉アニメーション</li>
<li>モダンなデザイン</li>
</ul>
</div>
</div>
@keyframes fadeIn {
0% {
opacity: 0;
transform: translateY(-10px);
}
100% {
opacity: 1;
transform: none;
}
}
.container-2 .btn-box button {
width: 100%;
padding: 20px;
background: #fff;
border: none;
border-radius: 12px;
font-size: 18px;
font-weight: 600;
color: #2c3e50;
cursor: pointer;
transition: all 0.3s ease;
text-align: left;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
position: relative;
}
.container-2 .btn-box button:hover {
transform: translateY(-2px);
box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
}
.container-2 .more {
max-height: 0;
overflow: hidden;
transition: max-height 0.4s ease;
background: #fff;
border-radius: 0 0 12px 12px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
margin-top: -12px;
position: relative;
z-index: -1;
}
.container-2 .more.appear {
max-height: 300px;
animation: fadeIn 0.4s ease;
}
.container-2 .more ul {
list-style: none;
padding: 30px 20px 20px;
margin: 0;
}
.container-2 .more li {
padding: 12px 0;
color: #555;
font-size: 15px;
border-bottom: 1px solid #f8f9fa;
}
.container-2 .more li:last-child {
border-bottom: none;
}
/* レスポンシブ対応 */
@media (max-width: 768px) {
.container-2 .btn-box button {
font-size: 14px;
padding: 15px 20px;
}
.container-2 .more ul {
padding: 15px;
}
}
【3】グラデーションアコーディオン
- 美しいグラデーション背景
- カラフルで魅力的
- アイコン付きボタン
- 滑らかなアニメーション
- 視覚的にインパクトのあるデザイン
<div class="container-3">
<div class="btn-box">
<button data-default-text="グラデーションアコーディオン" data-open-text="閉じる">グラデーションアコーディオン</button>
</div>
<div class="more">
<ul>
<li>美しいグラデーション背景</li>
<li>カラフルで魅力的</li>
<li>アイコン付きボタン</li>
<li>滑らかなアニメーション</li>
<li>視覚的にインパクトのあるデザイン</li>
</ul>
</div>
</div>
@keyframes fadeIn {
0% {
opacity: 0;
transform: translateY(-10px);
}
100% {
opacity: 1;
transform: none;
}
}
.container-3 .btn-box button {
width: 100%;
padding: 18px 25px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border: none;
border-radius: 10px;
font-size: 16px;
font-weight: 600;
color: #fff;
cursor: pointer;
transition: all 0.3s ease;
text-align: left;
position: relative;
overflow: hidden;
}
.container-3 .btn-box button::before {
content: '▼';
position: absolute;
right: 20px;
top: 50%;
transform: translateY(-50%);
transition: transform 0.3s ease;
}
.container-3 .btn-box button:hover {
background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
transform: scale(1.02);
}
.container-3 .more {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease;
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
border-radius: 0 0 10px 10px;
margin-top: -5px;
}
.container-3 .more.appear {
max-height: 300px;
animation: fadeIn 0.3s ease;
}
.container-3 .more.appear + .btn-box button::before {
transform: translateY(-50%) rotate(180deg);
}
.container-3 .more ul {
list-style: none;
padding: 25px;
margin: 0;
}
.container-3 .more li {
padding: 10px 0;
color: #fff;
font-weight: 500;
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}
.container-3 .more li:last-child {
border-bottom: none;
}
/* レスポンシブ対応 */
@media (max-width: 768px) {
.container-3 .btn-box button {
font-size: 14px;
padding: 15px 20px;
}
.container-3 .more ul {
padding: 15px;
}
}
【4】ボーダーアコーディオン
- ボーダーラインを活用
- ミニマルで洗練されたデザイン
- 開閉時のボーダーアニメーション
- タイポグラフィ重視
- ビジネス向けの落ち着いたデザイン
<div class="container-4">
<div class="btn-box">
<button data-default-text="ボーダーアコーディオン" data-open-text="閉じる">ボーダーアコーディオン</button>
</div>
<div class="more">
<ul>
<li>ボーダーラインを活用</li>
<li>ミニマルで洗練されたデザイン</li>
<li>開閉時のボーダーアニメーション</li>
<li>タイポグラフィ重視</li>
<li>ビジネス向けの落ち着いたデザイン</li>
</ul>
</div>
</div>
@keyframes fadeIn {
0% {
opacity: 0;
transform: translateY(-10px);
}
100% {
opacity: 1;
transform: none;
}
}
.container-4 .btn-box button {
width: 100%;
padding: 20px 0;
background: transparent;
border: none;
border-bottom: 2px solid #e0e0e0;
font-size: 18px;
font-weight: 500;
color: #333;
cursor: pointer;
transition: all 0.3s ease;
text-align: left;
position: relative;
}
.container-4 .btn-box button::after {
content: '';
position: absolute;
bottom: -2px;
left: 0;
width: 0;
height: 2px;
background: #007bff;
transition: width 0.3s ease;
}
.container-4 .btn-box button:hover::after {
width: 100%;
}
.container-4 .more {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease;
border-bottom: 2px solid #e0e0e0;
}
.container-4 .more.appear {
max-height: 300px;
animation: fadeIn 0.3s ease;
}
.container-4 .more ul {
list-style: none;
padding: 20px 0;
margin: 0;
}
.container-4 .more li {
padding: 12px 0;
color: #666;
font-size: 15px;
line-height: 1.6;
}
/* レスポンシブ対応 */
@media (max-width: 768px) {
.container-4 .btn-box button {
font-size: 14px;
padding: 15px 0;
}
.container-4 .more ul {
padding: 15px 0;
}
}
【5】アイコンアコーディオン
- +/×アイコン付き
- アイコンの回転アニメーション
- 直感的な操作感
- 視覚的なフィードバック
- ユーザビリティ重視のデザイン
<div class="container-5">
<div class="btn-box">
<button data-default-text="アイコンアコーディオン" data-open-text="閉じる">アイコンアコーディオン</button>
</div>
<div class="more">
<ul>
<li>+/×アイコン付き</li>
<li>アイコンの回転アニメーション</li>
<li>直感的な操作感</li>
<li>視覚的なフィードバック</li>
<li>ユーザビリティ重視のデザイン</li>
</ul>
</div>
</div>
@keyframes fadeIn {
0% {
opacity: 0;
transform: translateY(-10px);
}
100% {
opacity: 1;
transform: none;
}
}
.container-5 .btn-box button {
width: 100%;
padding: 20px 25px;
background: #f8f9fa;
border: 2px solid #dee2e6;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
color: #495057;
cursor: pointer;
transition: all 0.3s ease;
text-align: left;
position: relative;
}
.container-5 .btn-box button::before {
content: '+';
position: absolute;
right: 20px;
top: 50%;
transform: translateY(-50%) rotate(0deg);
font-size: 24px;
font-weight: 300;
transition: transform 0.3s ease;
color: #007bff;
}
.container-5 .btn-box button:hover {
background: #e9ecef;
border-color: #007bff;
}
.container-5 .more {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease;
background: #fff;
border: 2px solid #dee2e6;
border-top: none;
border-radius: 0 0 8px 8px;
}
.container-5 .more.appear {
max-height: 300px;
animation: fadeIn 0.3s ease;
}
.container-5:has(.more.appear) .btn-box button::before {
transform: translateY(-50%) rotate(45deg);
}
.container-5 .more ul {
list-style: none;
padding: 20px;
margin: 0;
}
.container-5 .more li {
padding: 10px 0;
color: #495057;
border-bottom: 1px solid #f8f9fa;
position: relative;
padding-left: 20px;
}
.container-5 .more li::before {
content: '•';
position: absolute;
left: 0;
color: #007bff;
font-weight: bold;
}
.container-5 .more li:last-child {
border-bottom: none;
}
/* レスポンシブ対応 */
@media (max-width: 768px) {
.container-5 .btn-box button {
font-size: 14px;
padding: 15px 20px;
}
.container-5 .more ul {
padding: 15px;
}
}
【6】ネオン風アコーディオン
- ネオンライト風の光る効果
- サイバーパンクな雰囲気
- ホバー時の光るアニメーション
- ダークテーマに最適
- インパクトのある演出
<div class="container-6">
<div class="btn-box">
<button data-default-text="ネオン風アコーディオン" data-open-text="閉じる">ネオン風アコーディオン</button>
</div>
<div class="more">
<ul>
<li>ネオンライト風の光る効果</li>
<li>サイバーパンクな雰囲気</li>
<li>ホバー時の光るアニメーション</li>
<li>ダークテーマに最適</li>
<li>インパクトのある演出</li>
</ul>
</div>
</div>
@keyframes fadeIn {
0% {
opacity: 0;
transform: translateY(-10px);
}
100% {
opacity: 1;
transform: none;
}
}
.container-6 .btn-box button {
width: 100%;
padding: 20px 25px;
background: #1a1a1a;
border: 2px solid #00ff88;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
color: #00ff88;
cursor: pointer;
transition: all 0.3s ease;
text-align: left;
position: relative;
text-shadow: 0 0 10px #00ff88;
box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}
.container-6 .btn-box button:hover {
background: #00ff88;
color: #1a1a1a;
text-shadow: none;
box-shadow: 0 0 30px rgba(0, 255, 136, 0.6);
transform: scale(1.02);
}
.container-6 .more {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease;
background: #1a1a1a;
border: 2px solid #00ff88;
border-top: none;
border-radius: 0 0 8px 8px;
box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}
.container-6 .more.appear {
max-height: 300px;
animation: fadeIn 0.3s ease;
}
.container-6 .more ul {
list-style: none;
padding: 20px;
margin: 0;
}
.container-6 .more li {
padding: 12px 0;
color: #00ff88;
border-bottom: 1px solid rgba(0, 255, 136, 0.3);
text-shadow: 0 0 5px #00ff88;
}
.container-6 .more li:last-child {
border-bottom: none;
}
/* レスポンシブ対応 */
@media (max-width: 768px) {
.container-6 .btn-box button {
font-size: 14px;
padding: 15px 20px;
}
.container-6 .more ul {
padding: 15px;
}
}
【7】ガラスモーフィズムアコーディオン
- ガラス効果の背景
- ぼかし効果でモダンな見た目
- 半透明で上品なデザイン
- 背景との調和が美しい
- 最新トレンドのデザイン
<div class="container-7">
<div class="btn-box">
<button data-default-text="ガラスモーフィズムアコーディオン" data-open-text="閉じる">ガラスモーフィズムアコーディオン</button>
</div>
<div class="more">
<ul>
<li>ガラス効果の背景</li>
<li>ぼかし効果でモダンな見た目</li>
<li>半透明で上品なデザイン</li>
<li>背景との調和が美しい</li>
<li>最新トレンドのデザイン</li>
</ul>
</div>
</div>
@keyframes fadeIn {
0% {
opacity: 0;
transform: translateY(-10px);
}
100% {
opacity: 1;
transform: none;
}
}
/* デザイン7専用の背景 */
.container-7 {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 20px;
border-radius: 15px;
margin-left: auto;
margin-right: auto;
}
.container-7 .btn-box button {
width: 100%;
padding: 20px 25px;
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 15px;
font-size: 16px;
font-weight: 600;
color: #fff;
cursor: pointer;
transition: all 0.3s ease;
text-align: left;
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
}
.container-7 .btn-box button:hover {
background: rgba(255, 255, 255, 0.2);
border-color: rgba(255, 255, 255, 0.3);
transform: translateY(-2px);
box-shadow: 0 12px 40px rgba(31, 38, 135, 0.5);
}
.container-7 .more {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease;
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
border-top: none;
border-radius: 0 0 15px 15px;
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
margin-top: -15px;
position: relative;
z-index: 1;
}
.container-7 .more.appear {
max-height: 300px;
animation: fadeIn 0.3s ease;
}
.container-7 .more ul {
list-style: none;
padding: 25px 20px 20px;
margin: 0;
}
.container-7 .more li {
padding: 12px 0;
color: #fff;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
font-weight: 400;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.container-7 .more li:last-child {
border-bottom: none;
}
/* レスポンシブ対応 */
@media (max-width: 768px) {
.container-7 {
margin: 0 10px 20px;
}
.container-7 .btn-box button {
font-size: 14px;
padding: 15px 20px;
}
.container-7 .more ul {
padding: 15px;
}
}