Communitygithub.com

프리미엄 모바일 메뉴

햄버거 버튼이 X 아이콘으로 변형되고, 전체 화면 오버레이 패널이 링크를 순차적으로 드러내며, 스크롤 잠금, 포커스 트랩, 그리고 모션 감소 처리를 갖춘 프리미엄 모바일 내비게이션을 구축합니다.

프리미엄 모바일 메뉴란 무엇인가요?

이 스킬은 단일 상태 함수에서 구동되는 프리미엄 모바일 메뉴를 구현하기 위한 완벽한 가이드를 제공합니다. 햄버거 버튼으로 시작하여 X로 변형되는 버튼, 순차적으로 드러나는 링크가 있는 전체 화면 패널, 스크롤 잠금, 포커스 트랩 및 모션 감소 처리를 포함합니다. 이 스킬은 모바일 메뉴, 햄버거/버거 버튼, 내비게이션 서랍, 오프-캔버스 메뉴가 요청되거나 메뉴의 스크롤 위치 손실, iOS에서의 고무줄 효과, 탭 포커스 누출, 작동하지 않는 닫기 버튼과 같은 문제가 발생할 때 사용하도록 설계되었습니다. 또한 헤더와 패널의 z-index 충돌, iOS 바디 잠금 실패, transition 문제 등 일반적인 함정 5가지를 해결합니다. 이 스킬은 모든 브라우저와 기기에서 프리미엄 느낌을 주는 접근성과 성능을 모두 보장합니다. Claude Code, Cursor 및 Codex를 포함한 모든 주요 AI 에이전트 플랫폼에서 사용할 수 있습니다.

지원 대상~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/brainzcode/premium-landing/tree/HEAD/plugins/premium-landing/skills/premium-mobile-menu

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

프리미엄 모바일 메뉴은(는) 무엇을 하나요?

모바일 메뉴는 하나의 부울 값에 연결된 네 가지 요소로 구성됩니다: 변형되는 버튼, 드러나는 패널, 뒤에 고정된 페이지, 그리고 내부에 갇힌 포커스. 거의 모든 고장난 메뉴는 이 네 가지 요소가 동기화되지 않아 발생합니다. 하나가 다른 곳에서, 다른 것에 의해 토글되기 때문입니다.

모든 것을 단일 set(state) 함수로 구동하세요. 클릭 핸들러에 classList.toggle()이 흩어져 있거나, 스크롤 잠금을 잊어버리는 별도의 "close" 경로가 없습니다. 하나의 함수, 모든 속성, 양방향.

구조

헤더가 패널보다 상위에 있고, 패널이 그 외 모든 것을 덮습니다:

.nav  { position: fixed; inset: 0 0 auto; z-index: 210 }  /* 버거가 여기에 있음 */
.menu { position: fixed; inset: 0 0 auto; z-index: 200; height: 100dvh }
<header class="nav">
  <a class="brand" href="/">silva</a>
  <button class="burger" id="menuBtn" type="button"
          aria-label="메뉴 열기" aria-expanded="false" aria-controls="menu">
    <i></i><i></i>
  </button>
</header>

<div class="menu" id="menu" role="dialog" aria-label="메뉴" tabindex="-1" inert>
  <nav class="menu__nav">
    <a href="#about"><span class="menu__idx">01</span> 소개</a>
    <a href="#work"><span class="menu__idx">02</span> 작업</a>
  </nav>
  <div class="menu__foot">…</div>
</div>

버거는 헤더에 그대로 있으며 제자리에서 변형됩니다. 이것은 열기 컨트롤이자 닫기 컨트롤이며, 이것이 헤더가 패널 위에 있어야 하는 이유입니다 — 트랩 1 참조.

버튼

44×44 대상, 22px의 보이는 막대. 막대는 절대 위치로 지정되며 변환(transform)이 아닌 마진(margin)으로 중앙 정렬되므로 transform 속성은 변형을 위해 자유롭게 유지됩니다:

.burger {
  position: relative; display: grid; place-items: center;
  width: 44px; height: 44px;
  background: none; border: 0; padding: 0; cursor: pointer;
  color: currentColor;
  -webkit-tap-highlight-color: transparent;
}

.burger i {
  position: absolute; left: 50%; top: 50%;
  margin: -.75px 0 0 -11px;          /* 중앙 정렬은 transform이 아닌 여기에 있음 */
  width: 22px; height: 1.5px;
  background: currentColor; border-radius: 2px;
  transition: transform .45s var(--ease);
}

.burger i:first-child { transform: translateY(-4px) }
.burger i:last-child  { transform: translateY(4px)  }

html.is-menu-open .burger i:first-child { transform: rotate(45deg)  }
html.is-menu-open .burger i:last-child  { transform: rotate(-45deg) }

두 막대가 하나의 중심점을 공유하므로, ±45° 회전으로 두 번째 키프레임이나 조정할 필요 없이 대칭적인 X를 만듭니다. translate(-50%,-50%)로 중앙 정렬하면 모든 변형 상태가 해당 translate를 다시 명시해야 하고 두 막대가 1픽셀씩 떨어집니다.

두 개의 막대를 사용하고, 세 개는 사용하지 마세요. 세 개의 막대로 X를 만들려면 가운데 막대가 페이드 아웃되고 바깥쪽 두 개가 모여야 하며, 페이드는 전환 중간에 회색 얼룩으로 보입니다. 두 개의 막대는 깔끔하게 변형됩니다. 3개의 막대 휴식 상태가 필수라면, 바깥쪽 막대를 translateY + rotate로 애니메이션하고 가운데 막대의 opacity는 회전이 시작되기 전에 사라지도록 더 짧은 지속 시간을 지정하세요.

막대를 이동시키기 위해 top/margin을 애니메이션하지 마세요. Transform만 사용하세요.

패널

.menu {
  position: fixed; left: 0; right: 0; top: 0;
  height: 100dvh;                      /* inset:0이 아님 — 트랩 2 참조 */
  z-index: 200;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: clamp(96px, 24vw, 150px) var(--gutter)
           max(clamp(28px, 7vw, 52px), env(safe-area-inset-bottom));
  background: var(--black); color: var(--white);
  overflow-y: auto; overscroll-behavior: contain;

  opacity: 0; visibility: hidden; transform: translateY(-12px);
  transition: opacity .45s var(--ease),
              transform .55s var(--ease),
              visibility 0s linear .45s;   /* 페이드가 끝난 후에만 숨김 */
}

.menu.is-open {
  opacity: 1; visibility: visible; transform: none;
  transition-delay: 0s;                    /* 들어갈 때 visibility 지연 취소 */
}

visibility는 이것을 키보드 안전하게 만듭니다. 즉, 닫힌 패널을 탭 순서에서 제거하는데, opacity: 0만으로는 할 수 없습니다. 지연된 visibility 전환이 핵심 트릭입니다 — 열 때는 즉시 보이고, 닫힐 때만 페이드 아웃이 재생된 후에 숨겨집니다.

순차적인 링크 드러내기는 고급스러워 보이게 만드는 요소입니다:

.menu__nav a {
  opacity: 0; transform: translateY(18px);
  transition: opacity .6s var(--ease), transform .6s var(--ease);
}
.menu.is-open .menu__nav a { opacity: 1; transform: none }

.menu.is-open .menu__nav a:nth-child(1) { transition-delay: .10s }
.menu.is-open .menu__nav a:nth-child(2) { transition-delay: .16s }
.menu.is-open .menu__nav a:nth-child(3) { transition-delay: .22s }
.menu.is-open .menu__nav a:nth-child(4) { transition-delay: .28s }
.menu.is-open .menu__nav a:nth-child(5) { transition-delay: .34s }

60ms 간격. ~40ms 미만에서는 하나의 블록처럼 보이고, ~90ms 이상에서는 마지막 항목이 늦게 느껴집니다. 알 수 없는 길이의 목록의 경우 각 항목에 style="--i:3"을 넣고 transition-delay: calc(.10s + var(--i) * .06s)를 사용하세요.

나갈 때는 지연을 제거하세요 (.menu:not(.is-open) .menu__nav a { transition-delay: 0s }). 순차적으로 사라지는 것은 닫힘이 느리게 느껴지게 만듭니다 — 닫힘은 즉각적이어야 합니다.

상태 함수

(function () {
  var btn   = document.getElementById('menuBtn');
  var panel = document.getElementById('menu');
  var root  = document.documentElement;
  var open  = false;
  var scrollY = 0;

  var FOCUSABLE = 'a[href], button:not([disabled]), input, select, textarea,' +
                  '[tabindex]:not([tabindex="-1"])';

  // 버거는 닫기 컨트롤이며 패널 외부에 있으므로 순환에 포함되어야 함
  function focusables() {
    return [btn].concat([].slice.call(panel.querySelectorAll(FOCUSABLE)));
  }

  function set(state) {
    if (state === open) return;
    open = state;

    panel.classList.toggle('is-open', open);
    root.classList.toggle('is-menu-open', open);
    btn.setAttribute('aria-expanded', String(open));
    btn.setAttribute('aria-label', open ? '메뉴 닫기' : '메뉴 열기');
    if (open) panel.removeAttribute('inert');
    else      panel.setAttribute('inert', '');

    if (open) {
      scrollY = window.scrollY;
      document.body.style.position = 'fixed';
      document.body.style.top = -scrollY + 'px';
      document.body.style.left = '0';
      document.body.style.right = '0';
      panel.focus({ preventScroll: true });
    } else {
      document.body.style.position = '';
      document.body.style.top = '';
      document.body.style.left = '';
      document.body.style.right = '';
      window.scrollTo(0, scrollY);
      btn.focus({ preventScroll: true });
    }
  }

  btn.addEventListener('click', function () { set(!open); });

  panel.querySelectorAll('a').forEach(function (a) {
    a.addEventListener('click', function () { set(false); });
  });

  document.addEventListener('keydown', function (e) {
    if (!open) return;
    if (e.key === 'Escape') { set(false); return; }
    if (e.key !== 'Tab') return;

    var list  = focusables();
    var first = list[0];
    var last  = list[list.length - 1];
    if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus(); }
    else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }
  });

  // 중단점을 넘는 크기 조정은 페이지를 잠긴 상태로 방치해서는 안 됨
  matchMedia('(min-width: 1101px)').addEventListener('change', function (e) {
    if (e.matches) set(false);
  });
})();

여기서 inert가 aria-hidden을 대체합니다. 포커스를 가질 수 있는 패널에 절대 aria-hidden="true"를 넣지 마세요. 포커스가 그 안에 있으면 접근성 트리에서 포커스된 요소를 숨기게 되는데, 이는 화면 판독기가 잘 처리하지 못하는 작성 오류입니다. inert는 포커스를 차단하고 하나의 속성으로 트리에서 숨깁니다.

aria-modal="true" 없이 role="dialog"를 사용합니다. aria-modal은 보조 기술에게 다이얼로그 외부의 모든 것을 무시하라고 지시하며, 닫기 버튼은 외부에 있습니다. aria-modal을 생략하거나 (위와 같이) 패널 내부에 실제 닫기 버튼을 넣으세요.

트랩 1 — 헤더가 패널보다 상위에 있어야 함

버거가 X로 변형되므로 패널이 떠 있는 동안에도 클릭 가능한 상태여야 합니다. 패널의 z-index가 헤더보다 높으면 X는 렌더링되지만 (헤더에 그려짐) 모든 클릭이 오버레이에 닿습니다. 메뉴는 보이는 출구 없이 함정이 됩니다 — "닫기 버튼이 작동하지 않음"으로 보고됩니다.

헤더에 패널보다 더 높은 z-index를 지정하고, 페이지의 다른 모든 고정 레이어 (쿠키 바와 고정 CTA가 일반적인 충돌입니다)에 대해 둘 다 확인하세요. 권장 값: 패널 200, 헤더 210, 토스트 9000.

고정 요소는 동일한 쌓임 맥락(stacking context)을 공유할 때만 서로에 대해 쌓입니다. 조상에 transform, filter, opacity < 1 또는 will-change가 있으면 새로운 맥락이 생성되어 전체 비교가 조용히 다시 부모가 됩니다.

트랩 2 — 바디의 overflow: hidden이 iOS에서 작동하지 않음

document.body.style.overflow = 'hidden'은 데스크톱 브라우저를 잠그지만 iOS Safari의 터치 드래그에는 아무 효과가 없습니다. 패널 뒤에서 페이지가 고무줄처럼 튕기고, 놓으면 사용자는 완전히 다른 곳에 있게 됩니다.

작동하는 잠금은 바디를 고정하고 오프셋을 복원하는 것이며, 이것이 위의 set()이 하는 일입니다. 함께 따라와야 할 두 가지 세부 사항:

  • 패널의 overscroll-behavior: contain은 패널 자체의 스크롤이 끝에 도달했을 때 페이지로 연결되는 것을 막습니다.
  • position을 지우는 동일한 호출에서 window.scrollTo(0, scrollY)로 복원합니다. 바디가 고정 해제된 후 scrollY를 읽으면 0이 됩니다.

헤더가 fixed가 아닌 position: sticky인 경우 이 잠금이 헤더를 깨뜨립니다. 고정된 바디는 스크롤 포트가 없으므로 sticky는 문서에 대해 해석되고 헤더는 페이지 상단으로 점프합니다. 화면 밖으로 나가며 버거도 함께 사라집니다. 메뉴가 열려 있는 동안 fixed로 전환하세요 (html.is-menu-open .nav { position: fixed; top: 0 }). lenis-smooth-scroll 스킬은 Lenis 쪽에서 동일한 실패를 다룹니다. 해당 라이브러리가 페이지에 있으면 두 번째 잠금 대신 lenis.stop()을 사용하여 둘을 쌓지 마세요.

0이 아닌 스크롤 오프셋에서 잠금을 테스트하세요. 스크롤 0에서는 깨진 잠금이 작동하는 잠금과 픽셀 단위로 동일합니다. 약 1200으로 스크롤하고, 열고, 드래그하고, 닫습니다: 위치는 전체에서 1200을 읽어야 합니다.

트랩 3 — display: none은 전환될 수 없음

display를 토글하면 애니메이션이 완전히 건너뛰어집니다: 패널이 즉시 나타나고 즉시 사라집니다. 위의 visibility + 지연 전환 패턴이 모든 곳에서 작동하는 버전입니다.

2024+ 기준을 요구할 의향이 있는 경우의 현대적 동등물:

.menu { display: none; opacity: 0;
        transition: opacity .45s var(--ease), display .45s allow-discrete }
.menu.is-open { display: flex; opacity: 1 }
@starting-style { .menu.is-open { opacity: 0 } }

@starting-style이 필요합니다. 이것 없이는 항목에 시작 값이 없고 종료만 애니메이션됩니다.

트랩 4 — 패널은 배경 블러에 적합하지 않음

전체 화면 패널의 backdrop-filter는 매 프레임 뒤에 있는 모든 것을 다시 샘플링하며, 중간급 Android에서는 항목 애니메이션을 한 자릿수 fps로 떨어뜨립니다. 한 빌드에서는 전체 뷰포트 블렌드/블러를 제거하여 드롭된 프레임이 34%에서 3%로 감소했습니다.

프리미엄 메뉴는 거의 항상 불투명한 브랜드 색상의 패널이지, 프로스트 글라스가 아닙니다. 디자인이 유리를 요구하는 경우, 화면의 일부를 덮는 작은 요소(시트)를 블러 처리하고, 전체 뷰포트를 블러 처리하지 마세요. liquid-glass 스킬을 참조하세요.

트랩 5 — 아무도 테스트하지 않는 상태

  • 열린 상태에서 중단점 너머로 크기 조정. 위에서 resize 리스너가 아닌 matchMedia로 처리되므로 드래그의 모든 프레임 대신 교차 시 한 번만 실행됩니다.
  • 클라이언트 측 경로 변경. Next/Astro/SPA 탐색에서 패널이 탐색 후에도 살아 있습니다. 라우터 이벤트에서 set(false)를 호출하고, 언마운트 시 바디 스타일을 정리하세요.
  • 연 후 뒤로 가기 버튼. 메뉴가 열릴 때 기록 항목을 푸시하는 경우, 뒤로 가기 버튼은 페이지를 떠나지 않고 닫아야 합니다.
  • 200%로 확대. 패널은 바닥글을 자르지 않고 스크롤해야 합니다.
  • 가로 모드 전화기. 스크롤 가능한 패널이 있는 100dvh가 처리합니다. 수직 중앙 정렬된 justify-content: center 목록은 그렇지 않습니다.

모션 감소

@media (prefers-reduced-motion: reduce) {
  .menu, .menu__nav a, .burger i {
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }
}

상태 변경은 유지하고, 안무는 버리세요. 패널은 여전히 나타나고 사라져야 합니다.

프리미엄으로 보이게 만드는 요소

위의 메커니즘은 기본입니다. 부트스트랩 서랍과 구분 짓는 선택은 다음과 같습니다:

  • 이징. 패널과 링크에 cubic-bezier(.16, 1, .3, 1) (expo-out). 빠른 출발, 긴 정착. 절대 ease나 linear를 사용하지 마세요.
  • 타이밍. 패널 450–600ms, 링크 600ms에 60ms 간격, 버거 변형 450ms. 300ms 미만은 움직임으로 인식되지 않습니다. 700ms 이상은 느리게 느껴집니다.
  • 타이포그래피. 링크 목록이 디자인입니다. clamp(1.65rem, 8.4vw, 2.9rem), 디스플레이 두께 300, line-height: 1, 대문자, 좁은 자간. 행 사이의 가는 구분선.
  • 색인 숫자. 각 레이블 앞에 작은 모노 또는 자간 좁은 대문자로 01 / 02 / 03, 흐릿한 톤으로 설정. 추가하기 싸고, 어떤 효과보다 인지된 품질에 더 많은 기여를 합니다.
  • 전체 행 히트 영역. 그 주변의 마진이 아닌 앵커 자체의 수직 패딩 clamp(14px, 3.4vw, 22px)로 전체 행을 탭할 수 있습니다.
  • :active 상태이지, :hover 상태가 아님. 휴대폰은 호버하지 않으며, 탭 후에 남아 있는 호버 스타일은 고장난 것처럼 보입니다.
  • 바닥글 블록 — 연락처 줄, 소셜, 단일 알약 CTA — justify-content: space-between으로 고정됨. 빈 하단 공간은 메뉴를 자리 표시자처럼 느끼게 만듭니다.
  • 패널 자체에 바운스나 스프링 없음. 전체 화면 표면의 오버슈트는 싸구려처럼 보입니다. 스프링 이징은 작은 요소를 위해 아껴두세요.

체크리스트

  • 하나의 set(state) 함수가 class, aria-expanded, 레이블, inert 및 스크롤 잠금을 소유합니다.
  • 헤더 z-index가 패널보다 높으며, 다른 모든 고정 요소에 대해 확인되었습니다.
  • iOS 바디 고정 잠금이 0이 아닌 스크롤에서 테스트되었습니다.
  • 포커스 트랩이 버거 버튼을 순환에 포함시킵니다 (패널 외부에 있음).
  • 모션 감소가 패널과 링크 지속 시간을 .01ms로 재정의합니다.
  • 중단점 크기 조정이 matchMedia로 처리되며, resize 리스너가 아닙니다.
  • inert가 aria-hidden 대신 사용되며, 패널에는 aria-modal이 없습니다.
  • 순차적인 링크 지연이 나갈 때 제거됩니다.
  • 100dvh가 사용되며, inset:0이 아닙니다 (iOS 뷰포트 문제).
  • 패널 자체에 바운스나 스프링 이징이 없습니다.

Individual skills in this repo

This repo contains 7 individual skills — each has its own dedicated page.

brainzcode/premium-landing

Add a studio or agency build credit to a website footer — "Site by <Studio>" linking to the studio's site. Use when finishing or shipping a site, adding a footer, or when asked for an agency credit, build credit, designed-by line, or attribution. Covers wording, placement opposite the client's copyright, markup for each stack, styling from the host site's tokens, and the sitewide-footer-link SEO footprint when the same credit runs across many client sites.

brainzcode/premium-landing

Build a complete premium landing page, either replicated from a reference screenshot/URL or designed from a written brief, in HTML, React, Next.js or Astro. Use when asked to build, design, replicate or clone a landing page, marketing page, or one-page site; when handed a design screenshot or Figma/Pinterest reference to turn into code; or when a landing page needs a full premium pass. Covers design tokens, section patterns, the layout traps that silently break grids and marquees, and screenshot-based responsive verification from 320px to 1920px.

brainzcode/premium-landing

Add Lenis smooth scrolling to a site correctly — setup, anchor offsets for sticky headers, scroll locking for modals and menus, reduced-motion handling. Use when asked for smooth scroll, Lenis, momentum/eased scrolling, or when smooth scroll broke a sticky header, a modal lock, or anchor links. Includes the sticky-position trap that only appears at non-zero scroll.

brainzcode/premium-landing

Build true Apple-style liquid glass in the browser — real refraction via SVG displacement maps, chromatic dispersion, specular edges. Use when asked for liquid glass, glassmorphism, frosted/glass cards, glass navbars, or when a blur-based "glass" effect looks flat. Includes the performance trap that makes backdrop-filter stutter on scroll and the contrast trap that makes text unreadable on glass.

brainzcode/premium-landing

Rebuild a design accurately from a supplied reference — a screenshot, PDF page, mockup or live URL — by measuring it numerically instead of eyeballing it. Use when asked to replicate, clone, match or rebuild a design "exactly", "1 to 1" or "with no mistakes", or when a build drifts from its reference. Covers extracting the true content box from a padded screenshot, deriving element positions as percentages, solving object-fit framing, and knowing when a reference cannot be matched.

brainzcode/premium-landing

Ship link previews and favicons that actually work - Open Graph and Twitter card tags, a correctly framed 1200x630 share image, and a full favicon set (SVG, ICO, apple-touch, maskable manifest icons). Use when asked for social sharing, OG image, open graph, twitter card, link preview, share image, favicon, app icon, apple touch icon, or web manifest. Also use when a shared link previews blank, shows the wrong image, or a favicon will not appear. Includes the absolute-URL trap that silently blanks every preview and the font trap that breaks SVG favicons on other machines.

brainzcode/premium-landing

Source free, licence-clear photography for a site from Unsplash — searching by mood rather than noun, sizing and cropping for the slot, honouring the API's hotlink and download-tracking requirements, and writing real alt text. Use when a page needs a hero image, section photography, avatars or card art and none was supplied; when placeholder greys need replacing with real imagery; or when asked to find, pick or swap photos for a design.

관련 스킬