← 一覧へ

Tab Menu / 07 吹き出し|Speech Bubble

デザイン見本

  • Tab 1
  • Tab 2
  • Tab 3
Good morning. This is the content of Tab 1.
Hello. This is the content of Tab 2.
Good evening. This is the content of Tab 3.

吹き出し(Speech Bubble)をモチーフにした、親しみやすいデザインです。選択中のタブからコンテンツに向かって三角形のポインタが伸びることで、関係性が視覚的に分かりやすくなっています。FAQやキャラクター紹介など、カジュアルなコンテンツに最適です。

実装コード

HTML
<div class="tab-container">
  <ul>
    <li class="selected" data-id="tab-1">Tab 1</li>
    <li data-id="tab-2">Tab 2</li>
    <li data-id="tab-3">Tab 3</li>
  </ul>
  <div class="tab-content selected" id="tab-1">
    Tab 1 のコンテンツ
  </div>
  <div class="tab-content" id="tab-2">
    Tab 2 のコンテンツ
  </div>
  <div class="tab-content" id="tab-3">
    Tab 3 のコンテンツ
  </div>
</div>
CSS
.tab-container ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 0;
  margin-bottom: 0;
  position: relative;
}

.tab-container ul li {
  flex: 1;
  padding: 16px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #e8f4fd;
  color: #1976d2;
  position: relative;
  border-radius: 12px 12px 0 0;
  margin-right: 4px;
}

.tab-container ul li:last-child {
  margin-right: 0;
}

.tab-container ul li.selected {
  color: #fff;
  background: #1976d2;
  box-shadow: 0 -4px 12px rgba(25, 118, 210, 0.3);
  z-index: 2;
}

.tab-container ul li.selected::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid #1976d2;
}

.tab-container ul li:not(.selected):hover {
  background: #bbdefb;
  color: #1565c0;
  transform: translateY(-2px);
}

.tab-container .tab-content {
  display: none;
  padding: 24px;
  min-height: 150px;
  background: #fff;
  border: 2px solid #1976d2;
  border-top: none;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.2);
  position: relative;
}

.tab-container .tab-content.selected {
  display: block;
  animation: bubbleIn 0.3s ease;
}

@keyframes bubbleIn {
  from { 
    opacity: 0; 
    transform: scale(0.95) translateY(-10px); 
  }
  to { 
    opacity: 1; 
    transform: scale(1) translateY(0); 
  }
}
JS
const tabContainer = document.querySelector('.tab-container');
const tabMenuItems = tabContainer.querySelectorAll('ul li');
const tabContents = tabContainer.querySelectorAll('.tab-content');

tabMenuItems.forEach(tabMenuItem => {
  tabMenuItem.addEventListener('click', () => {
    tabMenuItems.forEach(item => {
      item.classList.remove('selected');
    });
    tabMenuItem.classList.add('selected');

    tabContents.forEach(tabContent => {
      tabContent.classList.remove('selected');
    });
    document.getElementById(tabMenuItem.dataset.id).classList.add('selected');
  });
});