탐색

v2.1.0
탐색

이전·다음 페이지 탐색

글 하단에서 이전 페이지와 다음 페이지로 이동하는 링크입니다.

이 페이지의 내용

이전·다음 페이지 탐색은 글 하단에 링크 두 개를 나란히 배치합니다. 각 링크는 평평한 표면으로 표시되며, 이동할 페이지 제목 위에는 제목보다 눈에 덜 띄는 방향 레이블이 놓입니다. 링크는 rel="prev"와 rel="next"로 이전과 다음을 구분하고, 스타일시트가 이 값을 읽으므로 방향별 클래스는 필요하지 않습니다.

이전·다음 페이지 탐색

<nav class="pager max-w(560) mx-auto" aria-label="Guide pages">  <a class="pager-link" rel="prev" href="#installation">    <span class="pager-label">      <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M13.6362 7.5189A0.4947 0.4947 0 0 0 13.5 7.5L2.4755 7.5006A0.5 0.5 0 0 0 2.4266 8.4946L2.5 8.5H13.5A0.4947 0.4947 0 0 0 13.6362 8.4811A0.7009 0.7009 0 0 0 13.6362 7.5189Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(180 8 8)" /><path d="M8 4.5L13.2348 7.8313A0.2 0.2 0 0 1 13.2348 8.1687L8 11.5" transform="rotate(180 8 8)" />      </svg>Previous    </span>    <span class="pager-title">Installation</span>  </a>  <a class="pager-link" rel="next" href="#theming">    <span class="pager-label">      Next<svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M13.6362 7.5189A0.4947 0.4947 0 0 0 13.5 7.5L2.4755 7.5006A0.5 0.5 0 0 0 2.4266 8.4946L2.5 8.5H13.5A0.4947 0.4947 0 0 0 13.6362 8.4811A0.7009 0.7009 0 0 0 13.6362 7.5189Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><path d="M8 4.5L13.2348 7.8313A0.2 0.2 0 0 1 13.2348 8.1687L8 11.5" />      </svg>    </span>    <span class="pager-title">Theming</span>  </a></nav>
import ArrowLeftIcon from '@master/icons-react/native/16/soft/arrow-left'import ArrowRightIcon from '@master/icons-react/native/16/soft/arrow-right'<nav className="pager max-w(560) mx-auto" aria-label="Guide pages">  <a className="pager-link" rel="prev" href="#installation">    <span className="pager-label"><ArrowLeftIcon className="icon" />Previous</span>    <span className="pager-title">Installation</span>  </a>  <a className="pager-link" rel="next" href="#theming">    <span className="pager-label">Next<ArrowRightIcon className="icon" /></span>    <span className="pager-title">Theming</span>  </a></nav>
<script>  import ArrowLeftIcon from '@master/icons-svelte/native/16/soft/arrow-left'  import ArrowRightIcon from '@master/icons-svelte/native/16/soft/arrow-right'</script><nav class="pager max-w(560) mx-auto" aria-label="Guide pages">  <a class="pager-link" rel="prev" href="#installation">    <span class="pager-label"><ArrowLeftIcon class="icon" />Previous</span>    <span class="pager-title">Installation</span>  </a>  <a class="pager-link" rel="next" href="#theming">    <span class="pager-label">Next<ArrowRightIcon class="icon" /></span>    <span class="pager-title">Theming</span>  </a></nav>
<script setup>import ArrowLeftIcon from '@master/icons-vue/native/16/soft/arrow-left'import ArrowRightIcon from '@master/icons-vue/native/16/soft/arrow-right'</script><template>  <nav class="pager max-w(560) mx-auto" aria-label="Guide pages">    <a class="pager-link" rel="prev" href="#installation">      <span class="pager-label"><ArrowLeftIcon class="icon" />Previous</span>      <span class="pager-title">Installation</span>    </a>    <a class="pager-link" rel="next" href="#theming">      <span class="pager-label">Next<ArrowRightIcon class="icon" /></span>      <span class="pager-title">Theming</span>    </a>  </nav></template>

#속성 하나로 정하는 링크 위치

rel은 링크와 현재 페이지의 관계를 나타내는 HTML 속성이며, prev와 next는 이 속성에 사용할 수 있는 값입니다. 이전·다음 페이지 탐색의 각 링크에 해당 값을 지정하면 페이지 순서를 마크업으로 올바르게 표현할 수 있습니다. 스타일시트는 이 값을 읽어 다음 세 가지를 처리합니다.

  • 다음 페이지 링크는 행 끝에 배치되고, 링크의 텍스트도 끝에 맞춰 정렬됩니다.
  • 포인터를 올리면 화살표는 자신이 가리키는 방향으로 이동합니다. 다음 페이지는 앞으로, 이전 페이지는 뒤로 이동합니다. 오른쪽에서 왼쪽으로 읽는 페이지에서는 두 화살표의 방향이 뒤집힙니다.
  • 다음 페이지 링크만 있는 경우에도 사용자가 눈으로 찾거나 엄지로 누르기 쉬운 행 끝에 배치됩니다.

화살표는 레이블 안에 넣는 아이콘입니다. 16px Master Icons 그림을 레이블이 14px로 표시합니다. 이전 페이지에는 단어 앞에 arrow-left를, 다음 페이지에는 단어 뒤에 arrow-right를 넣습니다.

이동할 페이지가 없으면 해당 링크를 생략합니다. 가이드의 첫 페이지에는 다음 링크만, 마지막 페이지에는 이전 링크만 표시합니다.

첫 페이지

<nav class="pager max-w(560) mx-auto" aria-label="Guide pages">  <a class="pager-link" rel="next" href="#installation">    <span class="pager-label">      Next<svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M13.6362 7.5189A0.4947 0.4947 0 0 0 13.5 7.5L2.4755 7.5006A0.5 0.5 0 0 0 2.4266 8.4946L2.5 8.5H13.5A0.4947 0.4947 0 0 0 13.6362 8.4811A0.7009 0.7009 0 0 0 13.6362 7.5189Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><path d="M8 4.5L13.2348 7.8313A0.2 0.2 0 0 1 13.2348 8.1687L8 11.5" />      </svg>    </span>    <span class="pager-title">Installation</span>  </a></nav>
import ArrowRightIcon from '@master/icons-react/native/16/soft/arrow-right'<nav className="pager max-w(560) mx-auto" aria-label="Guide pages">  <a className="pager-link" rel="next" href="#installation">    <span className="pager-label">Next<ArrowRightIcon className="icon" /></span>    <span className="pager-title">Installation</span>  </a></nav>
<script>  import ArrowRightIcon from '@master/icons-svelte/native/16/soft/arrow-right'</script><nav class="pager max-w(560) mx-auto" aria-label="Guide pages">  <a class="pager-link" rel="next" href="#installation">    <span class="pager-label">Next<ArrowRightIcon class="icon" /></span>    <span class="pager-title">Installation</span>  </a></nav>
<script setup>import ArrowRightIcon from '@master/icons-vue/native/16/soft/arrow-right'</script><template>  <nav class="pager max-w(560) mx-auto" aria-label="Guide pages">    <a class="pager-link" rel="next" href="#installation">      <span class="pager-label">Next<ArrowRightIcon class="icon" /></span>      <span class="pager-title">Installation</span>    </a>  </nav></template>

#표면과 움직임

링크는 하나의 윤곽선으로 둘러싼 평평한 표면이며, 모서리에는 큰 컨트롤과 같은 둥글기를 적용합니다. 포인터를 올리면 표면이 한 단계 올라오고 화살표는 자신이 가리키는 방향으로 2px 이동합니다. 누르면 표면이 오목한 영역으로 들어갑니다. 동작 줄이기가 설정되어 있으면 화살표는 제자리에 머뭅니다.

이전·다음 페이지 탐색은 크기 컨테이너입니다. 컨테이너 자체의 너비가 26rem 미만이면 두 링크가 각각 컨테이너 전체 너비를 차지하며, 이전 페이지 링크가 위에 오도록 세로로 쌓입니다.

#이전·다음 페이지 탐색과 페이지네이션

이전·다음 페이지 탐색은 순서대로 읽는 페이지 사이를 이동할 수 있게 하며 각 페이지의 제목을 표시합니다. 페이지네이션은 긴 목록 하나를 번호가 매겨진 여러 페이지로 나누고 그 사이를 이동할 수 있게 합니다. 사이트에서 현재 페이지가 어디에 있는지는 브레드크럼으로 표시합니다.

#접근성

  • 페이지의 다른 탐색 영역과 구별할 수 있도록 링크를 aria-label 속성이 지정된 <nav> 요소에 넣습니다.
  • 링크의 접근성 이름은 레이블과 제목을 합친 형태입니다. 예를 들어 "다음, 테마 설정"처럼 구성됩니다. 제목만으로는 어느 방향으로 이동하는지 알 수 없으므로 레이블을 유지합니다.
  • 화살표는 aria-hidden="true"를 지정한 아이콘이며 스크린 리더에서 읽히지 않습니다.

#클래스

클래스설명
pager접근 가능한 이름이 있는 nav에 두 링크를 나란히 배치합니다. 컨테이너 너비가 26rem 미만이면 세로로 쌓입니다
pager-linkrel="prev" 또는 rel="next"가 지정된 링크 하나입니다. 평평한 표면에 포인터를 올리면 한 단계 올라옵니다. 다음 페이지 링크는 끝에 배치하고 텍스트도 끝에 맞춰 정렬합니다
pager-label제목 위에 ‘이전’ 또는 ‘다음’ 레이블을 낮은 강조로 표시하고, 링크가 향하는 방향을 가리키는 아이콘을 함께 넣습니다. 이전 페이지는 단어 앞에, 다음 페이지는 단어 뒤에 화살표를 넣습니다. 레이블이 아이콘을 14px로 맞추고, 오른쪽에서 왼쪽으로 읽는 페이지에서는 방향을 뒤집습니다.
pager-title링크 대상 페이지의 제목

#소스

@master/ui/components/pager.css
/* * Pager: the page before and the page after, at the foot of an article. * Two links side by side, each a flat face with a quiet word over the title of the page it leads to. The * links say which is which with rel="prev" and rel="next", and the stylesheet reads that: the next page * stands at the end with its words set to the end, and an arrow points the way each one goes. The arrow is an * icon in the markup, beside the word: the stylesheet sizes it, moves it and turns it in a right-to-left page. * A pager with only a next page keeps it at the end. * Under the pointer a link rises a step and its arrow moves 2px the way it points. In a narrow container the * two stack. * Geometry: a large control's corner, 14px by 16px of padding, 12px between the two. */@layer components.ui {  .pager {    container-type: inline-size;    display: grid;    grid-template-columns: repeat(2, minmax(0, 1fr));    gap: .75rem;    min-width: 0;    margin: 0;    padding: 0;    list-style: none;    @container (width < 26rem) {      .pager-link, .pager-link[rel~="next"] {        grid-column: 1 / -1;      }    }  }  .pager-link {    --pager-travel: 0px;    display: grid;    gap: .125rem;    min-width: 0;    padding: .875rem 1rem;    border-radius: calc(var(--radius-control-lg) * var(--corner-scale));    corner-shape: var(--corner-shape);    background: var(--color-surface-raised);    color: var(--color-text-body);    box-shadow: var(--shadow-flat);    text-decoration: none;    touch-action: manipulation;    -webkit-tap-highlight-color: transparent;    transition: box-shadow var(--duration-quick) var(--easing-glide);    /* The page after: at the end, with its words set to the end. */    &[rel~="next"] {      grid-column: 2;      justify-items: end;      text-align: end;    }    @media (hover: hover) {      &:hover {        --pager-travel: 2px;        box-shadow: var(--shadow-raised);      }    }    &:active {      background: var(--color-surface-inset);      box-shadow: var(--shadow-pressed);      transition-duration: var(--duration-press);    }    &:focus-visible {      @apply --focus-ring;    }    @media (prefers-reduced-motion: reduce) {      --pager-travel: 0px;      @media (hover: hover) {        &:hover {          --pager-travel: 0px;        }      }    }    @media (forced-colors: active) {      outline: 1px solid LinkText;      outline-offset: -1px;    }  }  /*   * The quiet word: Previous, Next. The icon beside it is its arrow, 14px, which the label holds before the word   * of the page before and after the word of the next.   */  .pager-label {    --icon-size: .875rem;    display: inline-flex;    align-items: center;    gap: .25rem;    margin: 0;    color: var(--color-text-muted);    font-size: .78125rem;    line-height: 1.25rem;    .icon {      transition: translate var(--duration-quick) var(--easing-glide);    }  }  /* Under the pointer an arrow moves the way it points: back for the page before, on for the next. */  .pager-link:not([rel~="next"]) .pager-label .icon {    translate: calc(-1 * var(--pager-travel)) 0;  }  .pager-link[rel~="next"] .pager-label .icon {    translate: var(--pager-travel) 0;  }  /* In a right-to-left page the same two drawings are turned round, and so is the way each moves. */  .pager-link:not([rel~="next"]) .pager-label:dir(rtl) .icon {    scale: -1 1;    translate: var(--pager-travel) 0;  }  .pager-link[rel~="next"] .pager-label:dir(rtl) .icon {    scale: -1 1;    translate: calc(-1 * var(--pager-travel)) 0;  }  /* The title of the page it leads to. */  .pager-title {    min-width: 0;    margin: 0;    color: var(--color-text-strong);    font-weight: var(--font-weight-control);    font-size: .9375rem;    line-height: 1.35;    text-wrap: balance;    overflow-wrap: anywhere;  }}