チャットバブル

送受信のメッセージ吹き出しを左右に並べたトーク画面。アバターや時刻、既読チェックまで揃い、最後の一通だけ少し遅れて既読色に変わります。

#css#chat

ライブデモ

コード

HTML
<!-- チャットバブル: 送受信メッセージを左右に並べた会話画面。最後の既読チェックだけ少し遅れて青く点灯する -->
<div class="stage">
  <section class="cb-panel" aria-label="吉田陽子さんとのトーク">
    <header class="cb-head">
      <span class="cb-avatar" style="--c1:#f6a86b;--c2:#f2607a" aria-hidden="true">陽</span>
      <div class="cb-head__info">
        <p class="cb-head__name">吉田 陽子</p>
        <p class="cb-head__status"><span class="cb-dot" aria-hidden="true"></span>オンライン</p>
      </div>
    </header>

    <ul class="cb-list">
      <li class="cb-row cb-row--in">
        <span class="cb-avatar cb-avatar--sm" style="--c1:#f6a86b;--c2:#f2607a" aria-hidden="true">陽</span>
        <div class="cb-group">
          <p class="cb-bubble cb-bubble--in">おはよう!今日の定例、資料はもうできてる?</p>
          <p class="cb-bubble cb-bubble--in">急ぎじゃないから大丈夫だよ〜</p>
          <p class="cb-meta">9:12</p>
        </div>
      </li>

      <li class="cb-row cb-row--out">
        <div class="cb-group">
          <p class="cb-bubble cb-bubble--out">おはよう、ちょうど今仕上げてるところ!</p>
          <p class="cb-bubble cb-bubble--out">10時までには共有するね</p>
          <p class="cb-meta cb-meta--out">9:14 <span class="cb-ticks" aria-label="既読">✓✓</span></p>
        </div>
      </li>

      <li class="cb-row cb-row--in">
        <span class="cb-avatar cb-avatar--sm" style="--c1:#f6a86b;--c2:#f2607a" aria-hidden="true">陽</span>
        <div class="cb-group">
          <p class="cb-bubble cb-bubble--in">了解、ありがとう!助かる〜</p>
          <p class="cb-meta">9:16</p>
        </div>
      </li>

      <li class="cb-row cb-row--out">
        <div class="cb-group">
          <p class="cb-bubble cb-bubble--out">こちらこそ、いつも早いレビューに感謝してます</p>
          <p class="cb-meta cb-meta--out">9:17 <span class="cb-ticks cb-ticks--wait" aria-label="送信済み・まもなく既読">✓✓</span></p>
        </div>
      </li>
    </ul>
  </section>
</div>
CSS
/* チャットバブル */
* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  font-family: "Hiragino Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at 88% 6%, rgba(99, 102, 241, .14) 0%, transparent 42%),
    radial-gradient(circle at 6% 94%, rgba(242, 96, 122, .1) 0%, transparent 45%),
    #0d0e16;
  color: #e7e9f3;
}

.cb-panel {
  width: min(380px, 92vw);
  border-radius: 22px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .09);
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .75);
  overflow: hidden;
}

.cb-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.cb-avatar {
  --c1: #818cf8;
  --c2: #6366f1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  box-shadow: 0 8px 18px -8px rgba(0, 0, 0, .6);
}
.cb-avatar--sm { width: 28px; height: 28px; font-size: 11.5px; align-self: flex-end; }

.cb-head__info { display: grid; gap: 3px; }
.cb-head__name { margin: 0; font-size: 14.5px; font-weight: 700; }
.cb-head__status {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: rgba(231, 233, 243, .55);
}
.cb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .5);
  animation: cb-pulse 2.2s ease-out infinite;
}
@keyframes cb-pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .45); }
  70% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.cb-list {
  list-style: none;
  margin: 0;
  padding: 18px 16px 20px;
  display: grid;
  gap: 14px;
}

.cb-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  opacity: 0;
  transform: translateY(10px);
  animation: cb-in .5s cubic-bezier(.22, 1, .36, 1) forwards;
}
.cb-row:nth-child(1) { animation-delay: .05s; }
.cb-row:nth-child(2) { animation-delay: .2s; }
.cb-row:nth-child(3) { animation-delay: .38s; }
.cb-row:nth-child(4) { animation-delay: .55s; }
@keyframes cb-in {
  to { opacity: 1; transform: translateY(0); }
}

.cb-row--out { justify-content: flex-end; }
.cb-group { display: grid; gap: 5px; max-width: 78%; }
.cb-row--out .cb-group { justify-items: end; }

.cb-bubble {
  margin: 0;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  border-radius: 16px;
  width: fit-content;
}
.cb-bubble--in {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .07);
  border-bottom-left-radius: 5px;
  color: #e7e9f3;
}
.cb-bubble--out {
  background: linear-gradient(135deg, #6d5efc, #4f46e5);
  border-bottom-right-radius: 5px;
  color: #fff;
  box-shadow: 0 10px 22px -12px rgba(79, 70, 229, .7);
}

.cb-meta {
  margin: 0;
  font-size: 10.5px;
  color: rgba(231, 233, 243, .4);
  display: flex;
  align-items: center;
  gap: 4px;
}
.cb-meta--out { justify-content: flex-end; }

.cb-ticks { color: #60a5fa; font-weight: 700; letter-spacing: -1px; }
.cb-ticks--wait {
  color: rgba(231, 233, 243, .35);
  animation: cb-read 4.5s ease forwards;
  animation-delay: 1.4s;
}
@keyframes cb-read {
  to { color: #60a5fa; }
}

@media (prefers-reduced-motion: reduce) {
  .cb-row { opacity: 1; transform: none; animation: none; }
  .cb-dot { animation: none; }
  .cb-ticks--wait { animation: none; color: #60a5fa; }
}

@media (max-width: 380px) {
  .cb-panel { border-radius: 18px; }
  .cb-list { padding: 14px 12px 16px; }
}
JavaScript
// チャットバブル: 演出はCSSアニメーションのみで完結するためJSの処理は不要
(() => {})();

🤖 AIエージェント用プロンプト

このままコピーしてAIに貼り付け「追加する場所」だけ書き換えればOK
あなたは熟練のフロントエンドエンジニアです。私のWebサイトに「チャットバブル」の効果を追加してください。

# 追加してほしい効果
チャットバブル(チャット & メディア)
送受信のメッセージ吹き出しを左右に並べたトーク画面。アバターや時刻、既読チェックまで揃い、最後の一通だけ少し遅れて既読色に変わります。

# 追加する場所
👉【ここに対象箇所を記入:例「トップのヒーローセクション」「お問い合わせボタン」「記事カードの一覧」など】

# 参考実装(この見た目・挙動を再現してください)
【HTML】
<!-- チャットバブル: 送受信メッセージを左右に並べた会話画面。最後の既読チェックだけ少し遅れて青く点灯する -->
<div class="stage">
  <section class="cb-panel" aria-label="吉田陽子さんとのトーク">
    <header class="cb-head">
      <span class="cb-avatar" style="--c1:#f6a86b;--c2:#f2607a" aria-hidden="true">陽</span>
      <div class="cb-head__info">
        <p class="cb-head__name">吉田 陽子</p>
        <p class="cb-head__status"><span class="cb-dot" aria-hidden="true"></span>オンライン</p>
      </div>
    </header>

    <ul class="cb-list">
      <li class="cb-row cb-row--in">
        <span class="cb-avatar cb-avatar--sm" style="--c1:#f6a86b;--c2:#f2607a" aria-hidden="true">陽</span>
        <div class="cb-group">
          <p class="cb-bubble cb-bubble--in">おはよう!今日の定例、資料はもうできてる?</p>
          <p class="cb-bubble cb-bubble--in">急ぎじゃないから大丈夫だよ〜</p>
          <p class="cb-meta">9:12</p>
        </div>
      </li>

      <li class="cb-row cb-row--out">
        <div class="cb-group">
          <p class="cb-bubble cb-bubble--out">おはよう、ちょうど今仕上げてるところ!</p>
          <p class="cb-bubble cb-bubble--out">10時までには共有するね</p>
          <p class="cb-meta cb-meta--out">9:14 <span class="cb-ticks" aria-label="既読">✓✓</span></p>
        </div>
      </li>

      <li class="cb-row cb-row--in">
        <span class="cb-avatar cb-avatar--sm" style="--c1:#f6a86b;--c2:#f2607a" aria-hidden="true">陽</span>
        <div class="cb-group">
          <p class="cb-bubble cb-bubble--in">了解、ありがとう!助かる〜</p>
          <p class="cb-meta">9:16</p>
        </div>
      </li>

      <li class="cb-row cb-row--out">
        <div class="cb-group">
          <p class="cb-bubble cb-bubble--out">こちらこそ、いつも早いレビューに感謝してます</p>
          <p class="cb-meta cb-meta--out">9:17 <span class="cb-ticks cb-ticks--wait" aria-label="送信済み・まもなく既読">✓✓</span></p>
        </div>
      </li>
    </ul>
  </section>
</div>

【CSS】
/* チャットバブル */
* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  font-family: "Hiragino Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at 88% 6%, rgba(99, 102, 241, .14) 0%, transparent 42%),
    radial-gradient(circle at 6% 94%, rgba(242, 96, 122, .1) 0%, transparent 45%),
    #0d0e16;
  color: #e7e9f3;
}

.cb-panel {
  width: min(380px, 92vw);
  border-radius: 22px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .09);
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .75);
  overflow: hidden;
}

.cb-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.cb-avatar {
  --c1: #818cf8;
  --c2: #6366f1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  box-shadow: 0 8px 18px -8px rgba(0, 0, 0, .6);
}
.cb-avatar--sm { width: 28px; height: 28px; font-size: 11.5px; align-self: flex-end; }

.cb-head__info { display: grid; gap: 3px; }
.cb-head__name { margin: 0; font-size: 14.5px; font-weight: 700; }
.cb-head__status {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: rgba(231, 233, 243, .55);
}
.cb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .5);
  animation: cb-pulse 2.2s ease-out infinite;
}
@keyframes cb-pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .45); }
  70% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.cb-list {
  list-style: none;
  margin: 0;
  padding: 18px 16px 20px;
  display: grid;
  gap: 14px;
}

.cb-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  opacity: 0;
  transform: translateY(10px);
  animation: cb-in .5s cubic-bezier(.22, 1, .36, 1) forwards;
}
.cb-row:nth-child(1) { animation-delay: .05s; }
.cb-row:nth-child(2) { animation-delay: .2s; }
.cb-row:nth-child(3) { animation-delay: .38s; }
.cb-row:nth-child(4) { animation-delay: .55s; }
@keyframes cb-in {
  to { opacity: 1; transform: translateY(0); }
}

.cb-row--out { justify-content: flex-end; }
.cb-group { display: grid; gap: 5px; max-width: 78%; }
.cb-row--out .cb-group { justify-items: end; }

.cb-bubble {
  margin: 0;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  border-radius: 16px;
  width: fit-content;
}
.cb-bubble--in {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .07);
  border-bottom-left-radius: 5px;
  color: #e7e9f3;
}
.cb-bubble--out {
  background: linear-gradient(135deg, #6d5efc, #4f46e5);
  border-bottom-right-radius: 5px;
  color: #fff;
  box-shadow: 0 10px 22px -12px rgba(79, 70, 229, .7);
}

.cb-meta {
  margin: 0;
  font-size: 10.5px;
  color: rgba(231, 233, 243, .4);
  display: flex;
  align-items: center;
  gap: 4px;
}
.cb-meta--out { justify-content: flex-end; }

.cb-ticks { color: #60a5fa; font-weight: 700; letter-spacing: -1px; }
.cb-ticks--wait {
  color: rgba(231, 233, 243, .35);
  animation: cb-read 4.5s ease forwards;
  animation-delay: 1.4s;
}
@keyframes cb-read {
  to { color: #60a5fa; }
}

@media (prefers-reduced-motion: reduce) {
  .cb-row { opacity: 1; transform: none; animation: none; }
  .cb-dot { animation: none; }
  .cb-ticks--wait { animation: none; color: #60a5fa; }
}

@media (max-width: 380px) {
  .cb-panel { border-radius: 18px; }
  .cb-list { padding: 14px 12px 16px; }
}

【JavaScript】
// チャットバブル: 演出はCSSアニメーションのみで完結するためJSの処理は不要
(() => {})();

# 外部ライブラリ
なし(追加ライブラリ不要)

# 守ってほしいこと
- 既存のHTML構造・レイアウト・デザインを壊さないこと。必要に応じてクラス名・色・サイズを私のサイトに合わせて調整してよい。
- クラス名やidが既存と衝突しないよう、必要なら接頭辞で名前空間を分けること。
- レスポンシブ対応と prefers-reduced-motion への配慮を入れること。
- 私のサイトのフレームワーク(React / Vue / 素のHTML など)に合わせて実装すること。不明な場合は素のHTML/CSS/JSで提示し、組み込み手順も説明すること。
- 変更後の確認手順も簡潔に教えてください。