탐색

v2.1.0
미디어

마키

끊임없이 흐르다가 자세히 살펴보려 하면 멈추는 콘텐츠 줄입니다.

이 페이지의 내용

마키는 히어로 영역 아래의 고객사 이름이나 인용문, 티커처럼 콘텐츠가 한 줄로 끊임없이 흘러가는 컴포넌트입니다. 별도의 표면이나 테두리 없이 양 끝이 뒤쪽 배경에 자연스럽게 녹아듭니다. CSS 애니메이션 하나로 움직입니다.

마키

<div class="marquee" role="group" aria-label="Teams that build with Master UI">  <ul class="marquee-track">    <li class="text-lg font-medium fg-text-muted">Northwind</li>    <li class="text-lg font-medium fg-text-muted">Lumen</li>    <li class="text-lg font-medium fg-text-muted">Aperture</li>    <li class="text-lg font-medium fg-text-muted">Kestrel</li>    <li class="text-lg font-medium fg-text-muted">Halcyon</li>    <li class="text-lg font-medium fg-text-muted">Meridian</li>    <li class="text-lg font-medium fg-text-muted">Solstice</li>  </ul>  <ul class="marquee-track" aria-hidden="true" inert>    <li class="text-lg font-medium fg-text-muted">Northwind</li>    <li class="text-lg font-medium fg-text-muted">Lumen</li>    <li class="text-lg font-medium fg-text-muted">Aperture</li>    <li class="text-lg font-medium fg-text-muted">Kestrel</li>    <li class="text-lg font-medium fg-text-muted">Halcyon</li>    <li class="text-lg font-medium fg-text-muted">Meridian</li>    <li class="text-lg font-medium fg-text-muted">Solstice</li>  </ul></div>
<div className="marquee" role="group" aria-label="Teams that build with Master UI">  <ul className="marquee-track">    <li className="text-lg font-medium fg-text-muted">Northwind</li>    <li className="text-lg font-medium fg-text-muted">Lumen</li>    <li className="text-lg font-medium fg-text-muted">Aperture</li>    <li className="text-lg font-medium fg-text-muted">Kestrel</li>    <li className="text-lg font-medium fg-text-muted">Halcyon</li>    <li className="text-lg font-medium fg-text-muted">Meridian</li>    <li className="text-lg font-medium fg-text-muted">Solstice</li>  </ul>  <ul className="marquee-track" aria-hidden="true" inert>    <li className="text-lg font-medium fg-text-muted">Northwind</li>    <li className="text-lg font-medium fg-text-muted">Lumen</li>    <li className="text-lg font-medium fg-text-muted">Aperture</li>    <li className="text-lg font-medium fg-text-muted">Kestrel</li>    <li className="text-lg font-medium fg-text-muted">Halcyon</li>    <li className="text-lg font-medium fg-text-muted">Meridian</li>    <li className="text-lg font-medium fg-text-muted">Solstice</li>  </ul></div>
<div class="marquee" role="group" aria-label="Teams that build with Master UI">  <ul class="marquee-track">    <li class="text-lg font-medium fg-text-muted">Northwind</li>    <li class="text-lg font-medium fg-text-muted">Lumen</li>    <li class="text-lg font-medium fg-text-muted">Aperture</li>    <li class="text-lg font-medium fg-text-muted">Kestrel</li>    <li class="text-lg font-medium fg-text-muted">Halcyon</li>    <li class="text-lg font-medium fg-text-muted">Meridian</li>    <li class="text-lg font-medium fg-text-muted">Solstice</li>  </ul>  <ul class="marquee-track" aria-hidden="true" inert>    <li class="text-lg font-medium fg-text-muted">Northwind</li>    <li class="text-lg font-medium fg-text-muted">Lumen</li>    <li class="text-lg font-medium fg-text-muted">Aperture</li>    <li class="text-lg font-medium fg-text-muted">Kestrel</li>    <li class="text-lg font-medium fg-text-muted">Halcyon</li>    <li class="text-lg font-medium fg-text-muted">Meridian</li>    <li class="text-lg font-medium fg-text-muted">Solstice</li>  </ul></div>
<template>  <div class="marquee" role="group" aria-label="Teams that build with Master UI">    <ul class="marquee-track">      <li class="text-lg font-medium fg-text-muted">Northwind</li>      <li class="text-lg font-medium fg-text-muted">Lumen</li>      <li class="text-lg font-medium fg-text-muted">Aperture</li>      <li class="text-lg font-medium fg-text-muted">Kestrel</li>      <li class="text-lg font-medium fg-text-muted">Halcyon</li>      <li class="text-lg font-medium fg-text-muted">Meridian</li>      <li class="text-lg font-medium fg-text-muted">Solstice</li>    </ul>    <ul class="marquee-track" aria-hidden="true" inert>      <li class="text-lg font-medium fg-text-muted">Northwind</li>      <li class="text-lg font-medium fg-text-muted">Lumen</li>      <li class="text-lg font-medium fg-text-muted">Aperture</li>      <li class="text-lg font-medium fg-text-muted">Kestrel</li>      <li class="text-lg font-medium fg-text-muted">Halcyon</li>      <li class="text-lg font-medium fg-text-muted">Meridian</li>      <li class="text-lg font-medium fg-text-muted">Solstice</li>    </ul>  </div></template>
"줄 위에 포인터를 올리거나 줄 안으로 포커스를 옮기면 멈춥니다."

#같은 줄을 담은 두 트랙

같은 줄을 두 번 작성하고 각각을 marquee-track으로 구성합니다. 두 트랙은 트랙 하나의 길이만큼 이동한 뒤 처음부터 다시 움직입니다. 두 번째 트랙이 첫 번째 트랙의 자리를 그대로 이어받으므로 이음새가 보이지 않습니다. 스크린 리더가 같은 줄을 한 번만 읽고 복제본 안의 어떤 요소에도 포커스가 가지 않도록, 시각적 효과를 위한 두 번째 트랙에는 aria-hidden="true"와 inert를 지정합니다.

트랙의 너비는 마키의 너비 이상이며, 항목은 트랙 전체에 고르게 배치됩니다. 이름이 세 개뿐인 줄도 양 끝까지 채워집니다.

#일시 정지

줄 위에 포인터가 있거나 줄 안에 키보드 포커스가 있으면 줄이 멈추므로 사용자가 인용문을 끝까지 읽거나 링크를 열 수 있습니다. WCAG는 다른 콘텐츠와 함께 표시되면서 5초 넘게 움직이는 콘텐츠에 이런 일시 정지 기능을 요구합니다.

prefers-reduced-motion: reduce 조건이 충족되면 콘텐츠가 전혀 움직이지 않습니다. 두 번째 트랙과 양 끝이 흐려지는 효과가 사라지고, 첫 번째 트랙의 콘텐츠는 필요한 만큼 줄을 바꿔 가운데 정렬된 상태로 표시됩니다.

#속도, 간격, 방향

--marquee-duration은 트랙 하나가 지나가는 데 걸리는 시간이며 기본값은 40초입니다. 줄이 길수록 같은 속도를 유지하는 데 더 긴 시간이 필요합니다. --marquee-gap은 항목 사이의 간격이고, --marquee-fade는 양 끝이 흐려지는 구간의 길이입니다. 두 줄을 배치할 때 두 번째 줄에 marquee-reverse 클래스를 적용하면 반대 방향으로 움직입니다.

두 줄로 배치한 카드

<div class="marquee" style="--marquee-gap: .75rem; --marquee-duration: 48s" role="group" aria-label="What teams say">  <ul class="marquee-track">    <li class="card card-flat w(280)">      <p>“It reads like the platform, only finished.”</p>      <p class="fg-text-muted text-xs">Mira Okafor, Northwind</p>    </li>    <li class="card card-flat w(280)">      <p>“We deleted four hundred lines of positioning script.”</p>      <p class="fg-text-muted text-xs">Jonas Thal, Lumen</p>    </li>    <li class="card card-flat w(280)">      <p>“The first dark mode we did not have to fix afterwards.”</p>      <p class="fg-text-muted text-xs">Ada Reyes, Kestrel</p>    </li>  </ul>  <ul class="marquee-track" aria-hidden="true" inert>    <li class="card card-flat w(280)">      <p>“It reads like the platform, only finished.”</p>      <p class="fg-text-muted text-xs">Mira Okafor, Northwind</p>    </li>    <li class="card card-flat w(280)">      <p>“We deleted four hundred lines of positioning script.”</p>      <p class="fg-text-muted text-xs">Jonas Thal, Lumen</p>    </li>    <li class="card card-flat w(280)">      <p>“The first dark mode we did not have to fix afterwards.”</p>      <p class="fg-text-muted text-xs">Ada Reyes, Kestrel</p>    </li>  </ul></div><div class="marquee marquee-reverse" style="--marquee-gap: .75rem; --marquee-duration: 56s" role="group" aria-label="More of what teams say">  <ul class="marquee-track">    <li class="card card-flat w(280)">      <p>“Every state is an attribute. Our tests got shorter.”</p>      <p class="fg-text-muted text-xs">Sena Ito, Halcyon</p>    </li>    <li class="card card-flat w(280)">      <p>“The select is still a select. That was the whole pitch.”</p>      <p class="fg-text-muted text-xs">Noor Haddad, Meridian</p>    </li>    <li class="card card-flat w(280)">      <p>“Corners that finally match the icons beside them.”</p>      <p class="fg-text-muted text-xs">Eli Brandt, Solstice</p>    </li>  </ul>  <ul class="marquee-track" aria-hidden="true" inert>    <li class="card card-flat w(280)">      <p>“Every state is an attribute. Our tests got shorter.”</p>      <p class="fg-text-muted text-xs">Sena Ito, Halcyon</p>    </li>    <li class="card card-flat w(280)">      <p>“The select is still a select. That was the whole pitch.”</p>      <p class="fg-text-muted text-xs">Noor Haddad, Meridian</p>    </li>    <li class="card card-flat w(280)">      <p>“Corners that finally match the icons beside them.”</p>      <p class="fg-text-muted text-xs">Eli Brandt, Solstice</p>    </li>  </ul></div>
<>  <div className="marquee" style={{ '--marquee-gap': '.75rem', '--marquee-duration': '48s' } as React.CSSProperties} role="group" aria-label="What teams say">    <ul className="marquee-track">      <li className="card card-flat w(280)">        <p>“It reads like the platform, only finished.”</p>        <p className="fg-text-muted text-xs">Mira Okafor, Northwind</p>      </li>      <li className="card card-flat w(280)">        <p>“We deleted four hundred lines of positioning script.”</p>        <p className="fg-text-muted text-xs">Jonas Thal, Lumen</p>      </li>      <li className="card card-flat w(280)">        <p>“The first dark mode we did not have to fix afterwards.”</p>        <p className="fg-text-muted text-xs">Ada Reyes, Kestrel</p>      </li>    </ul>    <ul className="marquee-track" aria-hidden="true" inert>      <li className="card card-flat w(280)">        <p>“It reads like the platform, only finished.”</p>        <p className="fg-text-muted text-xs">Mira Okafor, Northwind</p>      </li>      <li className="card card-flat w(280)">        <p>“We deleted four hundred lines of positioning script.”</p>        <p className="fg-text-muted text-xs">Jonas Thal, Lumen</p>      </li>      <li className="card card-flat w(280)">        <p>“The first dark mode we did not have to fix afterwards.”</p>        <p className="fg-text-muted text-xs">Ada Reyes, Kestrel</p>      </li>    </ul>  </div>  <div className="marquee marquee-reverse" style={{ '--marquee-gap': '.75rem', '--marquee-duration': '56s' } as React.CSSProperties} role="group" aria-label="More of what teams say">    <ul className="marquee-track">      <li className="card card-flat w(280)">        <p>“Every state is an attribute. Our tests got shorter.”</p>        <p className="fg-text-muted text-xs">Sena Ito, Halcyon</p>      </li>      <li className="card card-flat w(280)">        <p>“The select is still a select. That was the whole pitch.”</p>        <p className="fg-text-muted text-xs">Noor Haddad, Meridian</p>      </li>      <li className="card card-flat w(280)">        <p>“Corners that finally match the icons beside them.”</p>        <p className="fg-text-muted text-xs">Eli Brandt, Solstice</p>      </li>    </ul>    <ul className="marquee-track" aria-hidden="true" inert>      <li className="card card-flat w(280)">        <p>“Every state is an attribute. Our tests got shorter.”</p>        <p className="fg-text-muted text-xs">Sena Ito, Halcyon</p>      </li>      <li className="card card-flat w(280)">        <p>“The select is still a select. That was the whole pitch.”</p>        <p className="fg-text-muted text-xs">Noor Haddad, Meridian</p>      </li>      <li className="card card-flat w(280)">        <p>“Corners that finally match the icons beside them.”</p>        <p className="fg-text-muted text-xs">Eli Brandt, Solstice</p>      </li>    </ul>  </div></>
<div class="marquee" style="--marquee-gap: .75rem; --marquee-duration: 48s" role="group" aria-label="What teams say">  <ul class="marquee-track">    <li class="card card-flat w(280)">      <p>“It reads like the platform, only finished.”</p>      <p class="fg-text-muted text-xs">Mira Okafor, Northwind</p>    </li>    <li class="card card-flat w(280)">      <p>“We deleted four hundred lines of positioning script.”</p>      <p class="fg-text-muted text-xs">Jonas Thal, Lumen</p>    </li>    <li class="card card-flat w(280)">      <p>“The first dark mode we did not have to fix afterwards.”</p>      <p class="fg-text-muted text-xs">Ada Reyes, Kestrel</p>    </li>  </ul>  <ul class="marquee-track" aria-hidden="true" inert>    <li class="card card-flat w(280)">      <p>“It reads like the platform, only finished.”</p>      <p class="fg-text-muted text-xs">Mira Okafor, Northwind</p>    </li>    <li class="card card-flat w(280)">      <p>“We deleted four hundred lines of positioning script.”</p>      <p class="fg-text-muted text-xs">Jonas Thal, Lumen</p>    </li>    <li class="card card-flat w(280)">      <p>“The first dark mode we did not have to fix afterwards.”</p>      <p class="fg-text-muted text-xs">Ada Reyes, Kestrel</p>    </li>  </ul></div><div class="marquee marquee-reverse" style="--marquee-gap: .75rem; --marquee-duration: 56s" role="group" aria-label="More of what teams say">  <ul class="marquee-track">    <li class="card card-flat w(280)">      <p>“Every state is an attribute. Our tests got shorter.”</p>      <p class="fg-text-muted text-xs">Sena Ito, Halcyon</p>    </li>    <li class="card card-flat w(280)">      <p>“The select is still a select. That was the whole pitch.”</p>      <p class="fg-text-muted text-xs">Noor Haddad, Meridian</p>    </li>    <li class="card card-flat w(280)">      <p>“Corners that finally match the icons beside them.”</p>      <p class="fg-text-muted text-xs">Eli Brandt, Solstice</p>    </li>  </ul>  <ul class="marquee-track" aria-hidden="true" inert>    <li class="card card-flat w(280)">      <p>“Every state is an attribute. Our tests got shorter.”</p>      <p class="fg-text-muted text-xs">Sena Ito, Halcyon</p>    </li>    <li class="card card-flat w(280)">      <p>“The select is still a select. That was the whole pitch.”</p>      <p class="fg-text-muted text-xs">Noor Haddad, Meridian</p>    </li>    <li class="card card-flat w(280)">      <p>“Corners that finally match the icons beside them.”</p>      <p class="fg-text-muted text-xs">Eli Brandt, Solstice</p>    </li>  </ul></div>
<template>  <div class="marquee" style="--marquee-gap: .75rem; --marquee-duration: 48s" role="group" aria-label="What teams say">    <ul class="marquee-track">      <li class="card card-flat w(280)">        <p>“It reads like the platform, only finished.”</p>        <p class="fg-text-muted text-xs">Mira Okafor, Northwind</p>      </li>      <li class="card card-flat w(280)">        <p>“We deleted four hundred lines of positioning script.”</p>        <p class="fg-text-muted text-xs">Jonas Thal, Lumen</p>      </li>      <li class="card card-flat w(280)">        <p>“The first dark mode we did not have to fix afterwards.”</p>        <p class="fg-text-muted text-xs">Ada Reyes, Kestrel</p>      </li>    </ul>    <ul class="marquee-track" aria-hidden="true" inert>      <li class="card card-flat w(280)">        <p>“It reads like the platform, only finished.”</p>        <p class="fg-text-muted text-xs">Mira Okafor, Northwind</p>      </li>      <li class="card card-flat w(280)">        <p>“We deleted four hundred lines of positioning script.”</p>        <p class="fg-text-muted text-xs">Jonas Thal, Lumen</p>      </li>      <li class="card card-flat w(280)">        <p>“The first dark mode we did not have to fix afterwards.”</p>        <p class="fg-text-muted text-xs">Ada Reyes, Kestrel</p>      </li>    </ul>  </div>  <div class="marquee marquee-reverse" style="--marquee-gap: .75rem; --marquee-duration: 56s" role="group" aria-label="More of what teams say">    <ul class="marquee-track">      <li class="card card-flat w(280)">        <p>“Every state is an attribute. Our tests got shorter.”</p>        <p class="fg-text-muted text-xs">Sena Ito, Halcyon</p>      </li>      <li class="card card-flat w(280)">        <p>“The select is still a select. That was the whole pitch.”</p>        <p class="fg-text-muted text-xs">Noor Haddad, Meridian</p>      </li>      <li class="card card-flat w(280)">        <p>“Corners that finally match the icons beside them.”</p>        <p class="fg-text-muted text-xs">Eli Brandt, Solstice</p>      </li>    </ul>    <ul class="marquee-track" aria-hidden="true" inert>      <li class="card card-flat w(280)">        <p>“Every state is an attribute. Our tests got shorter.”</p>        <p class="fg-text-muted text-xs">Sena Ito, Halcyon</p>      </li>      <li class="card card-flat w(280)">        <p>“The select is still a select. That was the whole pitch.”</p>        <p class="fg-text-muted text-xs">Noor Haddad, Meridian</p>      </li>      <li class="card card-flat w(280)">        <p>“Corners that finally match the icons beside them.”</p>        <p class="fg-text-muted text-xs">Eli Brandt, Solstice</p>      </li>    </ul>  </div></template>

#사용을 피해야 할 경우

움직이는 글은 읽기 어렵고 거슬리기 쉽습니다. 이름, 짧은 호평, 장식용 티커처럼 사용자가 가볍게 훑어볼 수 있고 놓쳐도 되는 콘텐츠에 마키를 사용하세요. 사용자가 반드시 찾거나 비교하거나 조치를 취해야 하는 콘텐츠는 직접 움직일 수 있는 캐러셀이나 고정된 줄에 배치하세요.

#접근성

  • 마키에 role="group"을 지정하고, 줄에 어떤 콘텐츠가 담겼는지 설명하는 aria-label을 설정하세요.
  • 두 번째 트랙에 aria-hidden="true"를 지정해 스크린 리더에서 숨기고 inert로 만드세요. 링크와 버튼을 포함해 복제된 항목에는 포커스가 가지 않습니다.
  • 페이지의 다른 곳에서 확인할 수 없는 정보는 마키에 넣지 마세요.

#클래스

클래스설명
marquee행은 영역 밖으로 넘치는 콘텐츠를 잘라 내고, 마스크로 양쪽 끝에 페이드 효과를 적용합니다. 호버 또는 포커스 상태에서는 움직임을 멈춥니다. role="group"과 접근 가능한 이름을 지정하세요.
marquee-reverse두 행을 사용할 때 두 번째 행은 반대 방향으로 움직입니다.적용할 클래스는 marquee입니다
marquee-track행 하나의 너비는 마키의 너비 이상이어야 합니다. 같은 행을 두 번 작성하고 두 번째 행에 aria-hidden="true"와 inert를 설정합니다.

#사용자 지정 속성

속성기본값설명
--marquee-duration40s복제본 하나가 지나가는 데 걸리는 시간
--marquee-gap3rem항목 사이와 복제본 사이 간격
--marquee-fade4rem양쪽 끝의 페이드 길이

#소스

@master/ui/components/marquee.css
/* * Marquee: a row that passes by without end: the names of customers, a line of quotes, a ticker. * The row is written twice, each copy a track; both travel one track's length and start again, so the seam * never shows. The second copy is aria-hidden and inert: it exists for the eye only, and nothing in it takes focus. Both ends fade into whatever is * behind the marquee with a mask, so it needs no surface of its own. * It stops while the pointer or the keyboard is on it. With reduced motion nothing travels: the copy is * removed and the first track wraps onto as many centered lines as it needs. */@layer components.ui {  .marquee {    --marquee-duration: 40s;    --marquee-gap: 3rem;    --marquee-fade: 4rem;    display: flex;    gap: var(--marquee-gap);    min-width: 0;    /* Room for the focus ring of a link in the row, which the clip would cut; the margin gives the room back. */    margin-block: -.25rem;    padding-block: .25rem;    overflow: hidden;    mask-image: linear-gradient(to right, transparent, black var(--marquee-fade), black calc(100% - var(--marquee-fade)), transparent);    @media (hover: hover) {      &:hover .marquee-track {        animation-play-state: paused;      }    }    &:focus-within .marquee-track {      animation-play-state: paused;    }    /* The row passes the other way, for the second of two rows. */    &.marquee-reverse .marquee-track {      animation-direction: reverse;    }    @media (prefers-reduced-motion: reduce) {      mask-image: none;    }  }  /*   * One copy of the row. It is at least as wide as the marquee, with its items spread along it, so a short   * row still reaches both ends.   */  .marquee-track {    display: flex;    flex: none;    align-items: center;    justify-content: space-around;    gap: var(--marquee-gap);    min-width: 100%;    margin: 0;    padding: 0;    list-style: none;    /* Linear: the row moves at one speed, and an eased loop would pause at the seam. */    animation: marquee-travel var(--marquee-duration) linear infinite;    /* From right to left the second copy stands to the left of the first, so the row travels the other way. */    &:dir(rtl) {      --marquee-sign: -1;    }    @media (prefers-reduced-motion: reduce) {      flex: 1 1 auto;      flex-wrap: wrap;      justify-content: center;      row-gap: calc(var(--marquee-gap) / 2);      min-width: 0;      animation: none;      &[aria-hidden="true"] {        display: none;      }    }  }}@keyframes marquee-travel {  to {    translate: calc((-100% - var(--marquee-gap)) * var(--marquee-sign, 1)) 0;  }}