탐색

v2.1.0
탐색

탭 바

작은 화면용 앱의 주요 이동 대상을 화면 하단에 배치합니다.

이 페이지의 내용

탭 바는 작은 화면용 앱의 주요 이동 대상 3~5개를 엄지가 닿는 화면 하단에 배치합니다. 각 항목은 아이콘과 그 아래의 짧은 레이블로 구성됩니다. 현재 항목은 잉크색으로 표시하고, 아이콘 뒤에는 은은한 캡슐형 배경을 둡니다. 탭 바의 나머지 요소는 모두 무채색으로 표시합니다. 탭 바는 반투명한 서리 유리처럼 보이고 위쪽에 가는 경계선이 있으며, 홈 인디케이터와 겹치지 않도록 여백을 확보합니다.

탭 바

<div class="well h(320) max-w(380) mx-auto overflow-y-auto">  <div class="grid gap-sm p-md">    <div class="sheet p-lg text-sm">Today</div>    <div class="sheet p-lg text-sm">Continue reading</div>    <div class="sheet p-lg text-sm">New this week</div>    <div class="sheet p-lg text-sm">From your library</div>  </div>  <nav class="tabbar" aria-label="Main">    <a class="tabbar-item" href="#" aria-current="page">      <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M4 16.25L4 8.5672A1.25 1.25 0 0 1 4.4269 7.6265L9.1769 3.4702A1.25 1.25 0 0 1 10.8231 3.4702L15.5731 7.6265A1.25 1.25 0 0 1 16 8.5672L16 16.25A1.25 1.25 0 0 1 14.75 17.5L5.25 17.5A1.25 1.25 0 0 1 4 16.25Z" /><path d="M8 17.5L8 13.5A1 1 0 0 1 9 12.5L11 12.5A1 1 0 0 1 12 13.5L12 17.5" />      </svg><span class="tabbar-label">Home</span>    </a>    <a class="tabbar-item" href="#">      <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <circle cx="8.75" cy="8.75" r="5.75" /><path d="M12.8159 12.8159L17.5 17.5" />      </svg><span class="tabbar-label">Search</span>    </a>    <a class="tabbar-item" href="#">      <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M2.5 2.5L2.5 17.5" /><path d="M6.6667 5L6.6667 17.5" /><path d="M10.8333 4.1667L10.8333 17.5" /><path d="M14.1667 4.1667L18.3333 17.0833" />      </svg><span class="tabbar-label">Library</span>    </a>    <a class="tabbar-item" href="#">      <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <circle cx="10" cy="5.6" r="3" /><path d="M4 17.25V15.75C4 13.4 6.95 11.9 8.85 11.9H11.15C13.05 11.9 16 13.4 16 15.75V17.25" />      </svg><span class="tabbar-label">Profile</span>    </a>  </nav></div>
import HomeIcon from '@master/icons-react/native/20/soft/home'import SearchIcon from '@master/icons-react/native/20/soft/search'import LibraryIcon from '@master/icons-react/native/20/soft/library'import UserIcon from '@master/icons-react/native/20/soft/user'<div className="well h(320) max-w(380) mx-auto overflow-y-auto">  <div className="grid gap-sm p-md">    <div className="sheet p-lg text-sm">Today</div>    <div className="sheet p-lg text-sm">Continue reading</div>    <div className="sheet p-lg text-sm">New this week</div>    <div className="sheet p-lg text-sm">From your library</div>  </div>  <nav className="tabbar" aria-label="Main">    <a className="tabbar-item" href="#" aria-current="page">      <HomeIcon className="icon" /><span className="tabbar-label">Home</span>    </a>    <a className="tabbar-item" href="#">      <SearchIcon className="icon" /><span className="tabbar-label">Search</span>    </a>    <a className="tabbar-item" href="#">      <LibraryIcon className="icon" /><span className="tabbar-label">Library</span>    </a>    <a className="tabbar-item" href="#">      <UserIcon className="icon" /><span className="tabbar-label">Profile</span>    </a>  </nav></div>
<script>  import HomeIcon from '@master/icons-svelte/native/20/soft/home'  import SearchIcon from '@master/icons-svelte/native/20/soft/search'  import LibraryIcon from '@master/icons-svelte/native/20/soft/library'  import UserIcon from '@master/icons-svelte/native/20/soft/user'</script><div class="well h(320) max-w(380) mx-auto overflow-y-auto">  <div class="grid gap-sm p-md">    <div class="sheet p-lg text-sm">Today</div>    <div class="sheet p-lg text-sm">Continue reading</div>    <div class="sheet p-lg text-sm">New this week</div>    <div class="sheet p-lg text-sm">From your library</div>  </div>  <nav class="tabbar" aria-label="Main">    <a class="tabbar-item" href="#" aria-current="page">      <HomeIcon class="icon" /><span class="tabbar-label">Home</span>    </a>    <a class="tabbar-item" href="#">      <SearchIcon class="icon" /><span class="tabbar-label">Search</span>    </a>    <a class="tabbar-item" href="#">      <LibraryIcon class="icon" /><span class="tabbar-label">Library</span>    </a>    <a class="tabbar-item" href="#">      <UserIcon class="icon" /><span class="tabbar-label">Profile</span>    </a>  </nav></div>
<script setup>import HomeIcon from '@master/icons-vue/native/20/soft/home'import SearchIcon from '@master/icons-vue/native/20/soft/search'import LibraryIcon from '@master/icons-vue/native/20/soft/library'import UserIcon from '@master/icons-vue/native/20/soft/user'</script><template>  <div class="well h(320) max-w(380) mx-auto overflow-y-auto">    <div class="grid gap-sm p-md">      <div class="sheet p-lg text-sm">Today</div>      <div class="sheet p-lg text-sm">Continue reading</div>      <div class="sheet p-lg text-sm">New this week</div>      <div class="sheet p-lg text-sm">From your library</div>    </div>    <nav class="tabbar" aria-label="Main">      <a class="tabbar-item" href="#" aria-current="page">        <HomeIcon class="icon" /><span class="tabbar-label">Home</span>      </a>      <a class="tabbar-item" href="#">        <SearchIcon class="icon" /><span class="tabbar-label">Search</span>      </a>      <a class="tabbar-item" href="#">        <LibraryIcon class="icon" /><span class="tabbar-label">Library</span>      </a>      <a class="tabbar-item" href="#">        <UserIcon class="icon" /><span class="tabbar-label">Profile</span>      </a>    </nav>  </div></template>
미리보기를 스크롤하면 콘텐츠가 탭 바 뒤로 지나갑니다.

탭 바는 position: sticky를 사용해 스크롤 컨테이너 하단에 붙습니다. 셸 전체가 스크롤되지 않는 앱에서는 스크롤 영역 뒤에 배치하세요. 모양은 동일합니다.

탭 바 컴포넌트는 바 자체를 제공하며, 페이지 안에서의 위치는 레이아웃이 정합니다. 페이지에서는 본문 영역 뒤에 배치하고, 고정 셸에서는 푸터에 배치합니다.

#플로팅 탭 바

tabbar-floating은 여백을 두어 탭 바를 가장자리에서 띄우고, 표면과 같은 모서리 형태와 떠 있는 듯한 그림자를 적용합니다.

플로팅 탭 바

<div class="tray h(320) max-w(380) mx-auto p(0) overflow-y-auto">  <div class="grid gap-sm p-md">    <div class="sheet p-lg text-sm">Today</div>    <div class="sheet p-lg text-sm">Continue reading</div>    <div class="sheet p-lg text-sm">New this week</div>    <div class="sheet p-lg text-sm">From your library</div>  </div>  <nav class="tabbar tabbar-floating" aria-label="Main">    <a class="tabbar-item" href="#">      <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M4 16.25L4 8.5672A1.25 1.25 0 0 1 4.4269 7.6265L9.1769 3.4702A1.25 1.25 0 0 1 10.8231 3.4702L15.5731 7.6265A1.25 1.25 0 0 1 16 8.5672L16 16.25A1.25 1.25 0 0 1 14.75 17.5L5.25 17.5A1.25 1.25 0 0 1 4 16.25Z" /><path d="M8 17.5L8 13.5A1 1 0 0 1 9 12.5L11 12.5A1 1 0 0 1 12 13.5L12 17.5" />      </svg><span class="tabbar-label">Home</span>    </a>    <a class="tabbar-item" href="#" aria-current="page">      <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <circle cx="8.75" cy="8.75" r="5.75" /><path d="M12.8159 12.8159L17.5 17.5" />      </svg><span class="tabbar-label">Search</span>    </a>    <a class="tabbar-item" href="#">      <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M2.5 2.5L2.5 17.5" /><path d="M6.6667 5L6.6667 17.5" /><path d="M10.8333 4.1667L10.8333 17.5" /><path d="M14.1667 4.1667L18.3333 17.0833" />      </svg><span class="tabbar-label">Library</span>    </a>    <a class="tabbar-item" href="#">      <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <circle cx="10" cy="5.6" r="3" /><path d="M4 17.25V15.75C4 13.4 6.95 11.9 8.85 11.9H11.15C13.05 11.9 16 13.4 16 15.75V17.25" />      </svg><span class="tabbar-label">Profile</span>    </a>  </nav></div>
import HomeIcon from '@master/icons-react/native/20/soft/home'import SearchIcon from '@master/icons-react/native/20/soft/search'import LibraryIcon from '@master/icons-react/native/20/soft/library'import UserIcon from '@master/icons-react/native/20/soft/user'<div className="tray h(320) max-w(380) mx-auto p(0) overflow-y-auto">  <div className="grid gap-sm p-md">    <div className="sheet p-lg text-sm">Today</div>    <div className="sheet p-lg text-sm">Continue reading</div>    <div className="sheet p-lg text-sm">New this week</div>    <div className="sheet p-lg text-sm">From your library</div>  </div>  <nav className="tabbar tabbar-floating" aria-label="Main">    <a className="tabbar-item" href="#">      <HomeIcon className="icon" /><span className="tabbar-label">Home</span>    </a>    <a className="tabbar-item" href="#" aria-current="page">      <SearchIcon className="icon" /><span className="tabbar-label">Search</span>    </a>    <a className="tabbar-item" href="#">      <LibraryIcon className="icon" /><span className="tabbar-label">Library</span>    </a>    <a className="tabbar-item" href="#">      <UserIcon className="icon" /><span className="tabbar-label">Profile</span>    </a>  </nav></div>
<script>  import HomeIcon from '@master/icons-svelte/native/20/soft/home'  import SearchIcon from '@master/icons-svelte/native/20/soft/search'  import LibraryIcon from '@master/icons-svelte/native/20/soft/library'  import UserIcon from '@master/icons-svelte/native/20/soft/user'</script><div class="tray h(320) max-w(380) mx-auto p(0) overflow-y-auto">  <div class="grid gap-sm p-md">    <div class="sheet p-lg text-sm">Today</div>    <div class="sheet p-lg text-sm">Continue reading</div>    <div class="sheet p-lg text-sm">New this week</div>    <div class="sheet p-lg text-sm">From your library</div>  </div>  <nav class="tabbar tabbar-floating" aria-label="Main">    <a class="tabbar-item" href="#">      <HomeIcon class="icon" /><span class="tabbar-label">Home</span>    </a>    <a class="tabbar-item" href="#" aria-current="page">      <SearchIcon class="icon" /><span class="tabbar-label">Search</span>    </a>    <a class="tabbar-item" href="#">      <LibraryIcon class="icon" /><span class="tabbar-label">Library</span>    </a>    <a class="tabbar-item" href="#">      <UserIcon class="icon" /><span class="tabbar-label">Profile</span>    </a>  </nav></div>
<script setup>import HomeIcon from '@master/icons-vue/native/20/soft/home'import SearchIcon from '@master/icons-vue/native/20/soft/search'import LibraryIcon from '@master/icons-vue/native/20/soft/library'import UserIcon from '@master/icons-vue/native/20/soft/user'</script><template>  <div class="tray h(320) max-w(380) mx-auto p(0) overflow-y-auto">    <div class="grid gap-sm p-md">      <div class="sheet p-lg text-sm">Today</div>      <div class="sheet p-lg text-sm">Continue reading</div>      <div class="sheet p-lg text-sm">New this week</div>      <div class="sheet p-lg text-sm">From your library</div>    </div>    <nav class="tabbar tabbar-floating" aria-label="Main">      <a class="tabbar-item" href="#">        <HomeIcon class="icon" /><span class="tabbar-label">Home</span>      </a>      <a class="tabbar-item" href="#" aria-current="page">        <SearchIcon class="icon" /><span class="tabbar-label">Search</span>      </a>      <a class="tabbar-item" href="#">        <LibraryIcon class="icon" /><span class="tabbar-label">Library</span>      </a>      <a class="tabbar-item" href="#">        <UserIcon class="icon" /><span class="tabbar-label">Profile</span>      </a>    </nav>  </div></template>

#사용 기준

사용자가 자주 오가는 이동 대상의 중요도가 같다면 탭 바를 사용하세요. 한 페이지 안에서 보기를 전환할 때는 탭을 사용하고, 넓은 화면에서는 같은 이동 대상을 내비게이션 바 또는 내비게이션 목록에 배치하세요. 레이블은 한 단어로 쓰세요. 공간이 부족하면 인접 항목을 밀어내기 전에 레이블을 잘라 말줄임표로 표시합니다.

#접근성

  • 탭 바는 레이블이 있는 <nav>이며, 각 항목은 링크입니다. 현재 항목에는 aria-current="page" 속성을 지정합니다. 항목이 같은 위치에서 패널을 전환한다면 role="tablist"를 role="tab" 및 aria-selected와 함께 사용하세요. 두 경우의 표시 모양은 같습니다.
  • 모든 항목에 레이블을 표시하세요. 아이콘만으로는 의미를 추측해야 하며, 아이콘 아래의 단어가 항목의 이름을 알려 줍니다.
  • 각 항목의 높이는 최소 56px로, 터치 대상에 필요한 44px보다 충분히 큽니다. 항목은 전체 너비를 균등하게 나눠 씁니다.
  • 탭 바는 항목 아래에 env(safe-area-inset-bottom) 값만큼 안쪽 여백을 추가합니다. 이 여백이 적용되도록 뷰포트 메타 태그에 viewport-fit=cover를 설정하세요.

#클래스

클래스설명
tabbar레이블이 있는 nav에 적용하며, 스크롤할 때 하단에 고정되는 반투명 유리 패널입니다. 항목은 패널 너비를 균등하게 나눠 씁니다.
tabbar-floating가장자리에서 여백을 두고 띄운 바로, 표면의 모서리 스타일과 떠 있는 느낌을 주는 그림자가 적용됩니다.적용할 클래스는 tabbar입니다
tabbar-item이동할 위치를 나타내는 링크나 버튼으로, tabbar-label 위에 아이콘을 배치합니다.
tabbar-label아이콘 아래 레이블은 한 줄로 표시합니다. 인접 항목을 밀어내지 않도록 넘치는 부분은 말줄임표로 처리합니다.

#사용자 지정 속성

속성기본값설명
--tabbar-height3.5rem항목의 최소 높이
--tabbar-colorvar(--color-surface-base)패널에 입히는 색상

#소스

@master/ui/components/tabbar.css
/* * Tab bar: the few main destinations of a small-screen app, along the bottom edge under the thumb. * Each item is an icon over a short label. The current one is in ink and its icon rests on a soft pill. * The bar is a pane of frosted glass with a hairline above it, and it keeps clear of the home indicator. */@layer components.ui {  .tabbar {    --tabbar-height: 3.5rem;    --tabbar-color: var(--color-surface-base);    position: sticky;    bottom: 0;    z-index: 20;    display: grid;    grid-auto-columns: minmax(0, 1fr);    grid-auto-flow: column;    min-width: 0;    margin: 0;    /* Clear of the home indicator below and, on a phone turned on its side, of the notch at either end. */    padding: 0 max(.25rem, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(.25rem, env(safe-area-inset-left, 0px));    background: color-mix(in oklab, var(--tabbar-color) 78%, transparent);    box-shadow: inset 0 .5px 0 var(--color-line-strong);    backdrop-filter: blur(16px) saturate(1.7);    list-style: none;    /* Floating: a bar lifted off the edge, with the corner of a surface. */    &.tabbar-floating {      --tabbar-color: var(--color-surface-floating);      bottom: max(.75rem, env(safe-area-inset-bottom, 0px));      /* Its sides keep clear of a phone's notch too, turned on its side, as the edge bar's padding does. */      margin: .75rem max(.75rem, env(safe-area-inset-right, 0px)) .75rem max(.75rem, env(safe-area-inset-left, 0px));      padding: 0 .25rem;      border-radius: calc(var(--radius-surface) * var(--corner-scale) + 4px);      corner-shape: var(--corner-shape);      box-shadow: var(--shadow-floating);    }    @media (prefers-reduced-transparency: reduce) {      background: var(--tabbar-color);      backdrop-filter: none;    }    /* An outline, not a border: the bar keeps its height and the floating bar its corner. */    @media (forced-colors: active) {      outline: 1px solid CanvasText;      outline-offset: -1px;      background: Canvas;    }  }  .tabbar-item {    --icon-size: 1.25rem;    position: relative;    display: flex;    flex-direction: column;    align-items: center;    justify-content: center;    gap: .25rem;    min-width: 0;    min-height: var(--tabbar-height);    margin: 0;    padding: .375rem .25rem;    border: 0;    background: transparent;    color: var(--color-text-muted);    font: var(--font-weight-control) .6875rem/1 var(--font-family-sans);    font-feature-settings: inherit;    letter-spacing: .005em;    text-decoration: none;    cursor: pointer;    touch-action: manipulation;    isolation: isolate;    -webkit-tap-highlight-color: transparent;    transition: color var(--duration-quick) var(--easing-glide);    user-select: none;    -webkit-user-select: none;    /*     * The pill behind the icon: 56 by 28, centered on the icon's row, which stands half the gap and the 11px     * label above the item's middle. It grows in from a little smaller.     */    &::before {      content: '';      position: absolute;      top: calc(50% - (.25rem + .6875rem) / 2 - .875rem);      left: calc(50% - 1.75rem);      z-index: -1;      width: 3.5rem;      height: 1.75rem;      border-radius: 999px;      background: var(--color-surface-chip);      box-shadow: inset 0 0 0 .5px var(--color-line-hair);      opacity: 0;      scale: .8 .9;      transition-property: opacity, scale;      transition-duration: var(--duration-base);      transition-timing-function: var(--easing-glide);    }    @media (hover: hover) {      &:hover {        color: var(--color-text-strong);      }    }    &:is([aria-current="page"], [aria-selected="true"]) {      color: var(--color-text-strong);      &::before {        opacity: 1;        scale: 1;      }    }    &:active:not(:disabled, [aria-disabled="true"])::before {      opacity: 1;      scale: .94;      transition-duration: var(--duration-press);    }    &:focus-visible {      @apply --focus-ring;      outline-offset: -4px;      border-radius: calc(var(--radius-control) * var(--corner-scale));      corner-shape: var(--corner-shape);    }    /* The pill fades in without growing, and a press does not shrink it. */    @media (prefers-reduced-motion: reduce) {      &::before, &:active:not(:disabled, [aria-disabled="true"])::before {        scale: none;      }    }    @media (forced-colors: active) {      &:is([aria-current="page"], [aria-selected="true"]) {        color: Highlight;      }    }    &:is(:disabled, [aria-disabled="true"]) {      color: var(--color-text-disabled);      cursor: not-allowed;      @media (forced-colors: active) {        color: GrayText;      }    }  }  /* The word under the icon: one line, cut with an ellipsis before it pushes its neighbors. */  .tabbar-label {    overflow: hidden;    max-width: 100%;    /*     * A line as tall as the letters would clip the descenders of y, g and p at the ellipsis's edge. The line is a     * quarter taller and the margin takes that back, so the item and the pill above it keep their places.     */    margin-block: -.0859375rem;    line-height: 1.25;    text-overflow: ellipsis;    white-space: nowrap;  }}