탐색

v2.1.0
탐색

건너뛰기 링크

포커스를 받았을 때 표시되며 탐색 영역을 건너뛰는 페이지의 첫 번째 링크입니다.

이 페이지의 내용

건너뛰기 링크는 페이지의 첫 번째 링크입니다. 탐색 영역을 건너뛰어 본문으로 바로 이동하므로 키보드 사용자가 페이지마다 헤더의 모든 링크를 Tab 키로 순회할 필요가 없습니다. 이 링크는 모든 사용자의 문서에 포함되며 포커스를 받았을 때만 화면에 표시되므로 포인터로 탐색할 때는 보이지 않습니다.

건너뛰기 링크

<a class="skip" href="#content">Skip to content</a><header class="navbar">  <a class="navbar-brand" href="#home">Atlas</a>  <nav class="navbar-nav" aria-label="Main">    <a class="navbar-link" href="#projects" aria-current="page">Projects</a>    <a class="navbar-link" href="#deployments">Deployments</a>    <a class="navbar-link" href="#settings">Settings</a>  </nav></header><main class="p-lg" id="content" tabindex="-1">  <h1 class="heading">Projects</h1>  <p class="lead lead-sm">Fourteen projects in three teams.</p></main>
<>  <a className="skip" href="#content">Skip to content</a>  <header className="navbar">    <a className="navbar-brand" href="#home">Atlas</a>    <nav className="navbar-nav" aria-label="Main">      <a className="navbar-link" href="#projects" aria-current="page">Projects</a>      <a className="navbar-link" href="#deployments">Deployments</a>      <a className="navbar-link" href="#settings">Settings</a>    </nav>  </header>  <main className="p-lg" id="content" tabIndex={-1}>    <h1 className="heading">Projects</h1>    <p className="lead lead-sm">Fourteen projects in three teams.</p>  </main></>
<a class="skip" href="#content">Skip to content</a><header class="navbar">  <a class="navbar-brand" href="#home">Atlas</a>  <nav class="navbar-nav" aria-label="Main">    <a class="navbar-link" href="#projects" aria-current="page">Projects</a>    <a class="navbar-link" href="#deployments">Deployments</a>    <a class="navbar-link" href="#settings">Settings</a>  </nav></header><main class="p-lg" id="content" tabindex="-1">  <h1 class="heading">Projects</h1>  <p class="lead lead-sm">Fourteen projects in three teams.</p></main>
<template>  <a class="skip" href="#content">Skip to content</a>  <header class="navbar">    <a class="navbar-brand" href="#home">Atlas</a>    <nav class="navbar-nav" aria-label="Main">      <a class="navbar-link" href="#projects" aria-current="page">Projects</a>      <a class="navbar-link" href="#deployments">Deployments</a>      <a class="navbar-link" href="#settings">Settings</a>    </nav>  </header>  <main class="p-lg" id="content" tabindex="-1">    <h1 class="heading">Projects</h1>    <p class="lead lead-sm">Fourteen projects in three teams.</p>  </main></template>
미리보기 안을 클릭한 다음 Tab 키를 누르세요.

#마크업

링크가 동작하려면 두 가지 조건을 충족해야 합니다.

  1. 링크는 헤더 앞에 놓이며 페이지에서 포커스를 받을 수 있는 첫 번째 요소여야 합니다. 링크의 href에는 해시 기호(#) 뒤에 본문 영역의 ID를 붙여 지정하세요.
  2. 이동 대상에는 tabindex="-1"를 지정하세요. 프래그먼트 링크는 모든 브라우저에서 대상 위치로 스크롤하지만, 대상이 포커스를 받을 수 있을 때만 포커스도 이동합니다. 포커스가 이동하지 않으면 다음에 Tab 키를 눌렀을 때 방금 건너뛴 헤더로 돌아갑니다.

링크가 하는 일을 텍스트에 적으세요. ‘본문으로 건너뛰기’처럼 쓰면 됩니다. 사이드바가 긴 페이지에서는 첫 번째 링크 뒤에 ‘탐색 영역으로 건너뛰기’ 링크를 추가할 수 있습니다.

#표시 동작

포커스가 없을 때 링크는 뷰포트 위쪽 경계 밖에 있으며 투명하고 누를 수 없습니다. 이 상태에서도 탭 순서는 유지됩니다. 요소에 display: none을 적용하면 탭 순서에서 빠집니다. 포커스를 받으면 잉크색의 작은 컨트롤이 뷰포트 상단 모서리에서 8px 안쪽으로 내려와 스크롤할 때 상단에 붙는 내비게이션 바를 비롯한 페이지의 다른 요소 위에 표시됩니다. --skip-layer는 링크의 z-index를 정합니다.

건너뛰기 링크는 자체적으로 위치를 지정하는 몇 안 되는 컴포넌트 중 하나로, 뷰포트 모서리에 배치됩니다. 노치가 있는 휴대전화에서는 안전 영역 안에 표시됩니다.

#접근성

  • 본문 앞에 탐색 영역이 있는 모든 페이지에는 건너뛰기 링크가 필요합니다. WCAG 2.4.1 ‘블록 건너뛰기’는 페이지마다 반복되는 콘텐츠를 건너뛸 수단을 요구하며, 일반적으로 건너뛰기 링크로 이 기준을 충족합니다.
  • 링크는 :focus에서 표시되므로 :focus-visible에서만 표시할 때와 달리 스위치나 스크린 리더의 탐색 기능으로 링크에 도달한 사용자에게도 나타납니다.
  • 동작 줄이기가 활성화되면 링크가 내려오는 효과 없이 제자리에 나타납니다.
  • 페이지에 <main>과 같은 영역이 둘 이상 있으면 제목이나 aria-label로 이동 대상의 이름을 지정하세요. 사용자가 링크를 따라 이동한 뒤 어느 영역에 도착했는지 알 수 있습니다.

#클래스

클래스설명
skip링크는 id를 가리키는 앵커 요소에 둡니다. 위쪽 모서리에서 안으로 8px 떨어진 위치에 작은 컨트롤로 고정합니다. 포커스를 받으면 전경색으로 표시되며, 레이블이 길면 뷰포트 안에서 줄바꿈됩니다.

#사용자 지정 속성

속성기본값설명
--skip-layer1000상단에 붙는 내비게이션 바보다 위에 표시하기 위한 z-index

#소스

@master/ui/components/skip.css
/* * Skip: the first link of a page, which jumps past the navigation to the content. * It is in the document for everyone and on the screen only while it has focus: a reader who starts with the * Tab key meets it first, and nobody else sees it. Focused, it drops in at the top corner of the viewport as a * small control of ink, over everything else on the page. * It stands there because standing there is its job: fixed, 8px from the corner, clear of a notch. * Geometry: 38px tall with a control's corner, as a button is. */@layer components.ui {  .skip {    --skip-layer: 1000;    position: fixed;    z-index: var(--skip-layer);    inset-block-start: max(.5rem, env(safe-area-inset-top));    inset-inline-start: max(.5rem, env(safe-area-inset-left));    display: inline-flex;    align-items: center;    box-sizing: border-box;    min-height: 2.375rem;    padding: 0 1rem;    border-radius: calc(var(--radius-control) * var(--corner-scale));    corner-shape: var(--corner-shape);    @apply --control-ink;    color: var(--color-text-inverse);    font: var(--font-weight-control) .84375rem/1.2 var(--font-family-sans);    font-feature-settings: inherit;    text-decoration: none;    /*     * A long label wraps inside the viewport instead of leaving it: the width of the viewport less its scrollbar     * (a percentage of a fixed box's viewport, where 100vw would count the scrollbar too) and both insets.     */    max-width: calc(100% - max(.5rem, env(safe-area-inset-left)) - max(.5rem, env(safe-area-inset-right)));    padding-block: .5rem;    text-wrap: balance;    /* At rest it is above the viewport and cannot be pressed; it keeps its place in the tab order. */    opacity: 0;    translate: 0 calc(-100% - 1rem);    pointer-events: none;    transition: translate var(--duration-quick) var(--easing-glide), opacity var(--duration-quick) var(--easing-glide);    &:focus {      opacity: 1;      translate: 0 0;      pointer-events: auto;    }    &:focus-visible {      @apply --focus-ring;    }    /* Shown, it answers as the primary button does: a lighter face under the pointer, the well under a press. */    @media (hover: hover) {      &:focus:hover {        @apply --control-ink-hover;      }    }    &:focus:active {      @apply --control-ink-pressed;    }    /* Where words run from the right, the start corner is the right one, clear of the notch on that side. */    &:dir(rtl) {      inset-inline-start: max(.5rem, env(safe-area-inset-right));    }    @media (pointer: coarse) {      &::after {        @apply --touch-target;      }    }    /* With reduced motion it appears where it stands, without the drop, and still fades in and out. */    @media (prefers-reduced-motion: reduce) {      translate: none;      transition-property: opacity;    }    @media (forced-colors: active) {      outline: 1px solid ButtonText;      outline-offset: -1px;    }  }}