탐색

v2.1.0
본문

스레드

댓글과 답글을 표시하고, 각 답글을 해당 댓글에 선으로 연결합니다.

이 페이지의 내용

스레드는 문서, 리뷰, 이슈 아래에서 오가는 댓글과 답글을 묶어 보여 줍니다. 댓글은 한 열에 놓인 아바타와 그 옆의 본문으로 구성됩니다. 답글은 본문 아래에 놓입니다. 댓글의 아바타에서 아래로 뻗은 가는 선이 각 답글 쪽으로 꺾여 이어지므로, 들여쓰기에 의존하지 않고 선을 따라 어느 댓글에 달린 답글인지 알 수 있습니다.

스레드

<div class="card max-w(480) mx-auto">  <ol class="thread">    <li class="thread-item">      <span class="thread-avatar"><span class="avatar">AL</span></span>      <div class="thread-body">        <p class="thread-header">          <span class="thread-author">Ada Lovelace</span>          <time class="thread-meta" datetime="2026-11-12T09:12Z">2h</time>        </p>        <p class="thread-text">The focus ring is cut by the mask. Should it move to the group?</p>      </div>      <ol class="thread-replies">        <li class="thread-item">          <span class="thread-avatar"><span class="avatar avatar-sm">AT</span></span>          <div class="thread-body">            <p class="thread-header">              <span class="thread-author">Alan Turing</span>              <time class="thread-meta" datetime="2026-11-12T10:05Z">1h</time>            </p>            <p class="thread-text">              Yes. The group already has the corner, so the ring follows it.            </p>          </div>        </li>        <li class="thread-item">          <span class="thread-avatar"><span class="avatar avatar-sm">GH</span></span>          <div class="thread-body">            <p class="thread-header">              <span class="thread-author">Grace Hopper</span>              <time class="thread-meta" datetime="2026-11-12T10:31Z">35m</time>            </p>            <p class="thread-text">I will make the change this afternoon.</p>          </div>        </li>      </ol>    </li>    <li class="thread-item">      <span class="thread-avatar"><span class="avatar">KJ</span></span>      <div class="thread-body">        <p class="thread-header">          <span class="thread-author">Katherine Johnson</span>          <time class="thread-meta" datetime="2026-11-12T10:54Z">12m</time>        </p>        <p class="thread-text">The figures in the second table are right.</p>      </div>    </li>  </ol></div>
<div className="card max-w(480) mx-auto">  <ol className="thread">    <li className="thread-item">      <span className="thread-avatar"><span className="avatar">AL</span></span>      <div className="thread-body">        <p className="thread-header">          <span className="thread-author">Ada Lovelace</span>          <time className="thread-meta" dateTime="2026-11-12T09:12Z">2h</time>        </p>        <p className="thread-text">          The focus ring is cut by the mask. Should it move to the group?        </p>      </div>      <ol className="thread-replies">        <li className="thread-item">          <span className="thread-avatar"><span className="avatar avatar-sm">AT</span></span>          <div className="thread-body">            <p className="thread-header">              <span className="thread-author">Alan Turing</span>              <time className="thread-meta" dateTime="2026-11-12T10:05Z">1h</time>            </p>            <p className="thread-text">              Yes. The group already has the corner, so the ring follows it.            </p>          </div>        </li>        <li className="thread-item">          <span className="thread-avatar"><span className="avatar avatar-sm">GH</span></span>          <div className="thread-body">            <p className="thread-header">              <span className="thread-author">Grace Hopper</span>              <time className="thread-meta" dateTime="2026-11-12T10:31Z">35m</time>            </p>            <p className="thread-text">I will make the change this afternoon.</p>          </div>        </li>      </ol>    </li>    <li className="thread-item">      <span className="thread-avatar"><span className="avatar">KJ</span></span>      <div className="thread-body">        <p className="thread-header">          <span className="thread-author">Katherine Johnson</span>          <time className="thread-meta" dateTime="2026-11-12T10:54Z">12m</time>        </p>        <p className="thread-text">The figures in the second table are right.</p>      </div>    </li>  </ol></div>
<div class="card max-w(480) mx-auto">  <ol class="thread">    <li class="thread-item">      <span class="thread-avatar"><span class="avatar">AL</span></span>      <div class="thread-body">        <p class="thread-header">          <span class="thread-author">Ada Lovelace</span>          <time class="thread-meta" datetime="2026-11-12T09:12Z">2h</time>        </p>        <p class="thread-text">The focus ring is cut by the mask. Should it move to the group?</p>      </div>      <ol class="thread-replies">        <li class="thread-item">          <span class="thread-avatar"><span class="avatar avatar-sm">AT</span></span>          <div class="thread-body">            <p class="thread-header">              <span class="thread-author">Alan Turing</span>              <time class="thread-meta" datetime="2026-11-12T10:05Z">1h</time>            </p>            <p class="thread-text">              Yes. The group already has the corner, so the ring follows it.            </p>          </div>        </li>        <li class="thread-item">          <span class="thread-avatar"><span class="avatar avatar-sm">GH</span></span>          <div class="thread-body">            <p class="thread-header">              <span class="thread-author">Grace Hopper</span>              <time class="thread-meta" datetime="2026-11-12T10:31Z">35m</time>            </p>            <p class="thread-text">I will make the change this afternoon.</p>          </div>        </li>      </ol>    </li>    <li class="thread-item">      <span class="thread-avatar"><span class="avatar">KJ</span></span>      <div class="thread-body">        <p class="thread-header">          <span class="thread-author">Katherine Johnson</span>          <time class="thread-meta" datetime="2026-11-12T10:54Z">12m</time>        </p>        <p class="thread-text">The figures in the second table are right.</p>      </div>    </li>  </ol></div>
<template>  <div class="card max-w(480) mx-auto">    <ol class="thread">      <li class="thread-item">        <span class="thread-avatar"><span class="avatar">AL</span></span>        <div class="thread-body">          <p class="thread-header">            <span class="thread-author">Ada Lovelace</span>            <time class="thread-meta" datetime="2026-11-12T09:12Z">2h</time>          </p>          <p class="thread-text">The focus ring is cut by the mask. Should it move to the group?</p>        </div>        <ol class="thread-replies">          <li class="thread-item">            <span class="thread-avatar"><span class="avatar avatar-sm">AT</span></span>            <div class="thread-body">              <p class="thread-header">                <span class="thread-author">Alan Turing</span>                <time class="thread-meta" datetime="2026-11-12T10:05Z">1h</time>              </p>              <p class="thread-text">                Yes. The group already has the corner, so the ring follows it.              </p>            </div>          </li>          <li class="thread-item">            <span class="thread-avatar"><span class="avatar avatar-sm">GH</span></span>            <div class="thread-body">              <p class="thread-header">                <span class="thread-author">Grace Hopper</span>                <time class="thread-meta" datetime="2026-11-12T10:31Z">35m</time>              </p>              <p class="thread-text">I will make the change this afternoon.</p>            </div>          </li>        </ol>      </li>      <li class="thread-item">        <span class="thread-avatar"><span class="avatar">KJ</span></span>        <div class="thread-body">          <p class="thread-header">            <span class="thread-author">Katherine Johnson</span>            <time class="thread-meta" datetime="2026-11-12T10:54Z">12m</time>          </p>          <p class="thread-text">The figures in the second table are right.</p>        </div>      </li>    </ol>  </div></template>

#구조

thread는 목록이며, 각 thread-item은 댓글 하나를 나타냅니다. 자식 요소 세 개는 다음 순서로 배치합니다.

  1. thread-avatar는 아바타를 감쌉니다. 이 열을 따라 선이 아래로 이어집니다.
  2. thread-body에는 글 내용을 넣습니다. thread-header에 thread-author를 넣고 이름 옆에 thread-meta를 배치한 다음, 문단마다 thread-text를 하나씩 넣습니다. 페이지에서 문단에 어떤 여백을 지정하든 헤더와 본문 문단에는 자체 여백이 없습니다. 그 뒤에는 인용문이나 시각적 강조를 줄인 버튼 행 등 원하는 내용을 추가할 수 있습니다.
  3. 답글이 있으면 thread-replies에 이 댓글에 답하는 thread-item을 목록으로 담습니다.

댓글에 답글이 달리면 선이 자동으로 나타납니다. 각 답글은 세로선에서 직각으로 꺾여 나온 선으로 연결되며, 이 연결선은 답글의 아바타에 닿기 전에 끝납니다. 선은 반투명해서 두 겹이 되면 그 구간이 더 진하게 보이므로, 선분이 서로 겹치지 않게 그립니다.

#중첩

답글에도 답글을 달 수 있습니다. 답글 안에 thread-replies를 넣으면 선이 한 단계 안쪽으로 이어집니다. 댓글에는 기본 크기인 32px 아바타를 사용합니다. 답글의 아바타는 깊이에 관계없이 24px인 avatar-sm을 사용합니다.

두세 단계면 충분합니다. 단계가 하나 늘어날 때마다 본문에 쓸 수 있는 너비가 36px씩 줄어들어, 휴대전화에서는 중첩이 깊어지면 글을 표시할 공간이 부족해집니다. 그보다 깊어지면 답글 첫머리에 답하는 상대의 이름을 쓰고 같은 단계에 배치하세요.

중첩

<div class="card max-w(480) mx-auto">  <ol class="thread">    <li class="thread-item">      <span class="thread-avatar"><span class="avatar">GH</span></span>      <div class="thread-body">        <p class="thread-header">          <span class="thread-author">Grace Hopper</span>          <time class="thread-meta" datetime="2026-11-12T08:02Z">3h</time>        </p>        <p class="thread-text">Can we ship the contracts before the framework components?</p>      </div>      <ol class="thread-replies">        <li class="thread-item">          <span class="thread-avatar"><span class="avatar avatar-sm">AL</span></span>          <div class="thread-body">            <p class="thread-header">              <span class="thread-author">Ada Lovelace</span>              <time class="thread-meta" datetime="2026-11-12T08:40Z">2h</time>            </p>            <p class="thread-text">Yes, they do not depend on each other.</p>          </div>          <ol class="thread-replies">            <li class="thread-item">              <span class="thread-avatar"><span class="avatar avatar-sm">GH</span></span>              <div class="thread-body">                <p class="thread-header">                  <span class="thread-author">Grace Hopper</span>                  <time class="thread-meta" datetime="2026-11-12T08:44Z">2h</time>                </p>                <p class="thread-text">Then Tuesday.</p>              </div>            </li>          </ol>        </li>      </ol>    </li>  </ol></div>
<div className="card max-w(480) mx-auto">  <ol className="thread">    <li className="thread-item">      <span className="thread-avatar"><span className="avatar">GH</span></span>      <div className="thread-body">        <p className="thread-header">          <span className="thread-author">Grace Hopper</span>          <time className="thread-meta" dateTime="2026-11-12T08:02Z">3h</time>        </p>        <p className="thread-text">Can we ship the contracts before the framework components?</p>      </div>      <ol className="thread-replies">        <li className="thread-item">          <span className="thread-avatar"><span className="avatar avatar-sm">AL</span></span>          <div className="thread-body">            <p className="thread-header">              <span className="thread-author">Ada Lovelace</span>              <time className="thread-meta" dateTime="2026-11-12T08:40Z">2h</time>            </p>            <p className="thread-text">Yes, they do not depend on each other.</p>          </div>          <ol className="thread-replies">            <li className="thread-item">              <span className="thread-avatar"><span className="avatar avatar-sm">GH</span></span>              <div className="thread-body">                <p className="thread-header">                  <span className="thread-author">Grace Hopper</span>                  <time className="thread-meta" dateTime="2026-11-12T08:44Z">2h</time>                </p>                <p className="thread-text">Then Tuesday.</p>              </div>            </li>          </ol>        </li>      </ol>    </li>  </ol></div>
<div class="card max-w(480) mx-auto">  <ol class="thread">    <li class="thread-item">      <span class="thread-avatar"><span class="avatar">GH</span></span>      <div class="thread-body">        <p class="thread-header">          <span class="thread-author">Grace Hopper</span>          <time class="thread-meta" datetime="2026-11-12T08:02Z">3h</time>        </p>        <p class="thread-text">Can we ship the contracts before the framework components?</p>      </div>      <ol class="thread-replies">        <li class="thread-item">          <span class="thread-avatar"><span class="avatar avatar-sm">AL</span></span>          <div class="thread-body">            <p class="thread-header">              <span class="thread-author">Ada Lovelace</span>              <time class="thread-meta" datetime="2026-11-12T08:40Z">2h</time>            </p>            <p class="thread-text">Yes, they do not depend on each other.</p>          </div>          <ol class="thread-replies">            <li class="thread-item">              <span class="thread-avatar"><span class="avatar avatar-sm">GH</span></span>              <div class="thread-body">                <p class="thread-header">                  <span class="thread-author">Grace Hopper</span>                  <time class="thread-meta" datetime="2026-11-12T08:44Z">2h</time>                </p>                <p class="thread-text">Then Tuesday.</p>              </div>            </li>          </ol>        </li>      </ol>    </li>  </ol></div>
<template>  <div class="card max-w(480) mx-auto">    <ol class="thread">      <li class="thread-item">        <span class="thread-avatar"><span class="avatar">GH</span></span>        <div class="thread-body">          <p class="thread-header">            <span class="thread-author">Grace Hopper</span>            <time class="thread-meta" datetime="2026-11-12T08:02Z">3h</time>          </p>          <p class="thread-text">Can we ship the contracts before the framework components?</p>        </div>        <ol class="thread-replies">          <li class="thread-item">            <span class="thread-avatar"><span class="avatar avatar-sm">AL</span></span>            <div class="thread-body">              <p class="thread-header">                <span class="thread-author">Ada Lovelace</span>                <time class="thread-meta" datetime="2026-11-12T08:40Z">2h</time>              </p>              <p class="thread-text">Yes, they do not depend on each other.</p>            </div>            <ol class="thread-replies">              <li class="thread-item">                <span class="thread-avatar"><span class="avatar avatar-sm">GH</span></span>                <div class="thread-body">                  <p class="thread-header">                    <span class="thread-author">Grace Hopper</span>                    <time class="thread-meta" datetime="2026-11-12T08:44Z">2h</time>                  </p>                  <p class="thread-text">Then Tuesday.</p>                </div>              </li>            </ol>          </li>        </ol>      </li>    </ol>  </div></template>

#스레드와 메시지

스레드는 특정 주제를 다루는 토론입니다. 댓글은 모두 동등하며 어느 댓글에든 답글을 달 수 있습니다. 메시지는 양쪽이 주고받는 대화에서 한 차례의 발화를 나타내며, 작성자 쪽을 가리키는 말풍선으로 표시합니다. 답글이 달리지 않는 이벤트는 타임라인으로 표시합니다.

#접근성

  • 스레드는 <ol>로 작성하고, 답글은 <ol>을 중첩해 작성하세요. 중첩 구조가 댓글과 답글의 관계를 나타냅니다. 화면에서 선으로 보이는 관계를 스크린 리더는 중첩 단계와 답글 수를 읽어 전달합니다.
  • “2h”는 정확한 시각을 줄여 표시한 것이므로, 각 시각은 <time>으로 마크업하고 datetime을 지정하세요.
  • 선은 스타일시트에서 그리며 스크린 리더가 읽지 않습니다. 강제 색상 모드에서는 텍스트 색상으로 표시됩니다.
  • 작성자 이름 옆에 이니셜이나 사진을 표시하는 아바타는 장식입니다. 이름이 이미 텍스트로 표시되어 있기 때문입니다.

#클래스

클래스설명
thread댓글을 20px 간격으로 배치한 목록
thread-item댓글 하나를 표시합니다. 한 열에 아바타를 놓고 그 옆에 댓글 본문을, 본문 아래에 답글을 배치합니다.
thread-avatar아바타를 감싸는 열입니다. 답글이 이어지면 연결선이 아바타 아래에서 시작합니다.
thread-bodythread-header와 그 아래의 thread-text로 구성합니다. 첫 줄은 아바타의 세로 중앙에 맞춥니다
thread-header본문 첫 줄에 작성자 이름을 표시하고 그 옆에 시간을 표시합니다.
thread-text작성한 내용은 헤더 아래 본문에 표시합니다. 문단이 여러 개면 문단 사이 간격은 8px입니다.
thread-author작성자 이름을 진한 글자색으로 표시합니다.
thread-meta시각과 기타 부가 정보를 이름 옆에 눈에 덜 띄게 표시합니다.
thread-replies답글 목록은 thread-item 내부의 본문 뒤에 놓입니다. 각 답글은 thread-item이며, 꺾인 선으로 댓글과 연결됩니다.

#사용자 지정 속성

속성기본값설명
--thread-avatar2rem댓글 아바타 크기. 답글에는 1.5rem을 사용합니다.
--thread-gap.75rem아바타와 텍스트 사이 간격
--thread-space1.25rem댓글 사이 간격. 답글 사이 간격은 .875rem입니다.

#소스

@master/ui/components/thread.css
/* * Thread: comments and their replies, each joined to the comment it answers. * A comment is an avatar on a column and its words beside it. Replies stand under the words, and a hairline * runs down from the comment's avatar and turns into each of them: a reader follows a line, not an indent, * to see what answers what. The line is drawn in pieces that never overlap, since its ink is translucent: * the stretch under the avatar, an elbow into each reply, and the stretch on to the next one. * Geometry: a 32px avatar for a comment and 24px for a reply (avatar-sm), 12px between an avatar and its * words, 20px between comments and 14px between replies. The name stands level with the middle of its avatar. */@layer components.ui {  .thread {    --thread-avatar: 2rem;    --thread-gap: .75rem;    --thread-space: 1.25rem;    display: grid;    gap: var(--thread-space);    min-width: 0;    margin: 0;    padding: 0;    color: var(--color-text-body);    font-size: .875rem;    line-height: 1.55;    list-style: none;  }  /* One comment: the avatar's column, the words, and under the words its replies. */  .thread-item {    /* Where this comment's line runs, for the replies that turn off it. */    --thread-rail: calc(var(--thread-avatar) / 2);    position: relative;    display: grid;    grid-template-columns: var(--thread-avatar) minmax(0, 1fr);    column-gap: var(--thread-gap);    min-width: 0;  }  /* The avatar's column. Under the avatar the line begins, when replies follow. */  .thread-avatar {    display: flex;    grid-area: 1 / 1;    flex-direction: column;    align-items: center;    min-width: 0;    /* The avatar fills the column: a comment's is --thread-avatar, a reply's the size smaller. A size class on it still wins. */    .avatar {      --avatar-size: var(--thread-avatar);    }    &:has(~ .thread-replies)::after {      content: '';      flex: 1 1 0;      width: 1px;      margin-block-start: .25rem;      background: var(--color-line-divider);    }    @media (forced-colors: active) {      &:has(~ .thread-replies)::after {        background: CanvasText;      }    }  }  /* The words: a line that says who and when, then what they wrote. The first line is level with the middle of the avatar. */  .thread-body {    display: grid;    grid-area: 1 / 2;    gap: .125rem;    min-width: 0;    padding-block-start: calc((var(--thread-avatar) - 1.25rem) / 2);    overflow-wrap: anywhere;  }  /* The line with the name on it, and what is said quietly beside the name. */  .thread-header {    display: flex;    flex-wrap: wrap;    align-items: baseline;    gap: 0 .5rem;    min-width: 0;    margin: 0;  }  /* What they wrote. Several paragraphs stand 8px apart. */  .thread-text {    min-width: 0;    margin: 0;    text-wrap: pretty;    & + & {      margin-block-start: .375rem;    }  }  /* Who wrote it. */  .thread-author {    color: var(--color-text-strong);    font-weight: var(--font-weight-control);    line-height: 1.25rem;  }  /* When, and anything else said quietly beside the name. */  .thread-meta {    color: var(--color-text-muted);    font-size: .78125rem;    font-variant-numeric: tabular-nums;    line-height: 1.25rem;  }  /* The replies, under the words. Their avatars are a size smaller. */  .thread-replies {    --thread-parent: var(--thread-rail);    --thread-avatar: 1.5rem;    --thread-space: .875rem;    display: grid;    grid-area: 2 / 2;    min-width: 0;    margin: 0;    padding: 0;    list-style: none;    .thread-item {      padding-block-start: var(--thread-space);      /* The elbow: down the comment's line, then round into this reply's avatar, stopping 4px short of it. */      &::before {        content: '';        position: absolute;        inset-block-start: 0;        inset-inline-start: calc(-1 * (var(--thread-gap) + var(--thread-parent)) - .5px);        width: calc(var(--thread-gap) + var(--thread-parent) - .25rem);        height: calc(var(--thread-space) + var(--thread-avatar) / 2);        border-block-end: 1px solid var(--color-line-divider);        border-inline-start: 1px solid var(--color-line-divider);        border-end-start-radius: .625rem;        pointer-events: none;      }      /* The line goes on to the next reply, from where the elbow leaves it. */      &:not(:last-child)::after {        content: '';        position: absolute;        inset-block: calc(var(--thread-space) + var(--thread-avatar) / 2 - .625rem) 0;        inset-inline-start: calc(-1 * (var(--thread-gap) + var(--thread-parent)) - .5px);        width: 1px;        background: var(--color-line-divider);        pointer-events: none;      }      @media (forced-colors: active) {        &::before {          border-color: CanvasText;        }        &:not(:last-child)::after {          background: CanvasText;        }      }    }  }}