탐색

v2.1.0
피드백

플래시

링크가 가리키는 위치에 나타났다가 서서히 사라지는 윤곽선입니다.

이 페이지의 내용

플래시는 링크가 가리키는 위치를 보여 줍니다. 제목, 행, 댓글, 카드처럼 id가 있는 요소에 flash 클래스를 적용합니다. 주소의 프래그먼트가 해당 id와 일치하면 요소 둘레에 윤곽선이 나타났다가 2초에 걸쳐 사라집니다. 여러 항목 중 하나를 가리키는 링크를 따라온 사용자는 대상 항목을 바로 알아볼 수 있습니다. 스크립트로 아무것도 추가하지 않으며, 주소 자체가 상태를 결정합니다.

플래시

<div class="card max-w(480) mx-auto">  <p class="m(0) text-sm">    Jump to <a class="link" href="#comment-ada">Ada's comment</a> or <a class="link" href="#comment-grace">Grace's reply</a>.  </p>  <ol class="thread">    <li class="thread-item flash" id="comment-ada" style="--flash-offset: 1rem">      <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:12">2h</time>        </p>        <p class="thread-text">The focus ring is cut by the mask. Should it move to the group?</p>      </div>    </li>    <li class="thread-item flash" id="comment-grace" style="--flash-offset: 1rem">      <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-12T10:31">35m</time>        </p>        <p class="thread-text">I will make the change this afternoon.</p>      </div>    </li>  </ol></div>
<div className="card max-w(480) mx-auto">  <p className="m(0) text-sm">    Jump to <a className="link" href="#comment-ada">Ada's comment</a> or <a className="link" href="#comment-grace">Grace's reply</a>.  </p>  <ol className="thread">    <li className="thread-item flash" id="comment-ada" style={{ '--flash-offset': '1rem' } as React.CSSProperties}>      <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:12">2h</time>        </p>        <p className="thread-text">          The focus ring is cut by the mask. Should it move to the group?        </p>      </div>    </li>    <li className="thread-item flash" id="comment-grace" style={{ '--flash-offset': '1rem' } as React.CSSProperties}>      <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-12T10:31">35m</time>        </p>        <p className="thread-text">I will make the change this afternoon.</p>      </div>    </li>  </ol></div>
<div class="card max-w(480) mx-auto">  <p class="m(0) text-sm">    Jump to <a class="link" href="#comment-ada">Ada's comment</a> or <a class="link" href="#comment-grace">Grace's reply</a>.  </p>  <ol class="thread">    <li class="thread-item flash" id="comment-ada" style="--flash-offset: 1rem">      <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:12">2h</time>        </p>        <p class="thread-text">The focus ring is cut by the mask. Should it move to the group?</p>      </div>    </li>    <li class="thread-item flash" id="comment-grace" style="--flash-offset: 1rem">      <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-12T10:31">35m</time>        </p>        <p class="thread-text">I will make the change this afternoon.</p>      </div>    </li>  </ol></div>
<template>  <div class="card max-w(480) mx-auto">    <p class="m(0) text-sm">      Jump to <a class="link" href="#comment-ada">Ada's comment</a> or <a class="link" href="#comment-grace">Grace's reply</a>.    </p>    <ol class="thread">      <li class="thread-item flash" id="comment-ada" style="--flash-offset: 1rem">        <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:12">2h</time>          </p>          <p class="thread-text">The focus ring is cut by the mask. Should it move to the group?</p>        </div>      </li>      <li class="thread-item flash" id="comment-grace" style="--flash-offset: 1rem">        <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-12T10:31">35m</time>          </p>          <p class="thread-text">I will make the change this afternoon.</p>        </div>      </li>    </ol>  </div></template>
링크를 따라가면 해당 댓글 둘레에 윤곽선이 나타났다가 사라집니다.

#동작 방식

브라우저는 id가 주소의 프래그먼트와 일치하는 요소를 페이지의 :target으로 지정합니다. flash 클래스는 해당 요소 둘레에 윤곽선을 그리고, 그 윤곽선이 서서히 사라지게 합니다. 주소가 상태를 결정하므로 다음 두 가지 동작이 따릅니다.

  • 다른 페이지의 링크를 따라가든, 같은 페이지의 링크를 따라가든, 주소를 붙여 넣든 같은 요소에 플래시가 표시됩니다.
  • 다른 프래그먼트 링크를 따라가면 플래시가 새 대상으로 이동합니다. 같은 프래그먼트의 링크를 다시 따라가면 플래시가 재생되지 않습니다.

요소를 둘러싸는 선은 윤곽선입니다. 레이아웃 공간을 차지하지 않고 요소의 모서리 모양을 따르며 가상 요소도 필요하지 않습니다. 요소의 표면, 그림자, 호버 상태는 그대로 유지됩니다. 따라서 카드, 표의 행, 제목, 댓글에 같은 클래스를 사용할 수 있습니다.

#내비게이션 바와의 간격

프래그먼트 링크는 대상이 뷰포트 맨 위에 오도록 스크롤합니다. 스크롤할 때 뷰포트 상단에 붙는 내비게이션 바가 있으면 대상이 그 뒤에 가려집니다. flash 클래스는 브라우저가 스크롤을 멈췄을 때 대상이 뷰포트 상단에서 얼마나 떨어져 있을지를 --flash-offset 사용자 지정 속성으로 정합니다. 기본값은 5rem입니다. 페이지 상단에 고정된 영역의 높이에 약간의 여유를 더한 값으로 설정합니다.

#동작 줄이기

사용자가 동작 줄이기를 설정하면 윤곽선이 서서히 사라지는 효과가 적용되지 않습니다. 요소가 대상인 동안 가는 윤곽선이 유지되어 움직임 없이도 대상을 알 수 있습니다.

#플래시와 강조 표시

플래시는 위치를 잠시 표시합니다. 텍스트가 있는 동안 그 자리에서 계속 강조하려면 강조 표시를 사용합니다. 방금 일어난 일을 알리려면 토스트를 사용합니다.

#접근성

  • 플래시는 시각적 표시입니다. 링크나 조작 요소가 아닌 대상에는 tabindex="-1"을 지정합니다. 그러면 해당 위치로 이동할 때 포커스도 함께 옮겨가며, 다음에 Tab을 누르면 그 대상부터 탐색이 이어집니다.
  • 윤곽선은 요소 바깥쪽으로 4px 떨어져 있고 콘텐츠를 가리지 않으므로 텍스트의 대비가 유지됩니다.
  • 강제 색상 모드에서는 대상의 윤곽선이 시스템 강조 색상으로 표시되며 서서히 사라지는 효과가 적용되지 않습니다.

#클래스

클래스설명
flashid가 있는 요소가 URL의 대상이 되면 요소의 모서리 모양을 따르는 윤곽선이 나타났다가 서서히 사라집니다.

#사용자 지정 속성

속성기본값설명
--flash-offset5rem브라우저가 요소를 스크롤해 배치할 때 뷰포트 상단과 요소 사이의 간격을 지정합니다

#소스

@master/ui/components/flash.css
/* * Flash: where a link has landed. * On anything with an id. When that id is the fragment of the address, the element is the page's :target: * a ring of ink stands around it and fades away in two seconds, so a reader who followed a link to one * heading, one row or one comment among many sees which. Nothing is added by script: the address is the state. * The ring is an outline. It takes no room, follows the element's own corner, needs no pseudo-element and * leaves the element's face, shadow and hover as they are, so it works on a card, a table row and a line of * text alike. * The element also keeps clear of what is fixed at the top of the page: --flash-offset is how far below the * top edge the browser scrolls it to, 5rem unless told otherwise. * With reduced motion the ring does not fade: a hairline stays around the target instead. */@layer components.ui {  .flash {    --flash-offset: 5rem;    --flash-color: color-mix(in oklab, var(--color-text-strong) 42%, transparent);    scroll-margin-top: var(--flash-offset);    &:target {      animation: flash-fade 2s var(--easing-glide) 200ms backwards;    }    @media (prefers-reduced-motion: reduce) {      &:target {        outline: 1px solid var(--color-line-mark);        outline-offset: .25rem;        animation: none;      }    }    @media (forced-colors: active) {      &:target {        outline: 2px solid Highlight;        outline-offset: .25rem;        animation: none;      }    }  }}@keyframes flash-fade {  0%, 30% {    outline: 2px solid var(--flash-color);    outline-offset: .25rem;  }  100% {    outline: 2px solid transparent;    outline-offset: .25rem;  }}