Ir al contenido
English

Navegar

Escribe para buscar. Pulsa Escape para cerrar.

    Componentes · js

    Barra de navegación (navbar)

    La cabecera de un sitio: marca, enlaces, acciones y, en pantallas estrechas, un panel que se pliega. El servidor la envía funcionando: por encima del punto de plegado es una barra, y por debajo el panel llega abierto y apilado bajo la marca, así que ningún enlace queda fuera del alcance. En init aparece el botón de hamburguesa, el panel se pliega, Escape y un clic fuera lo cierran, y una cabecera pegajosa se condensa en cuanto la página baja. No es un panel lateral: este panel es contenido en el flujo, no atrapa el foco y nunca bloquea la página.

    CSS: css/components/navbar.css (en ivolt.css). JS: @intervolutions/ivolt/navbar o auto.js. Añadido en la v0.6.

    Cabecera pegajosafixtures/navbar/basic.htmlAbrir sola — Cabecera pegajosa
    <header class="iv-navbar" data-iv-component="navbar" data-iv-sticky="true">
      <div class="iv-navbar__inner">
        <a class="iv-navbar__brand" href="#nav-note">
          <svg viewBox="0 0 32 32" aria-hidden="true" focusable="false">
            <defs><linearGradient id="nav-brand" x1="0" y1="0" x2="32" y2="32" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#73DFFF"/><stop offset="1" stop-color="#0B6B8A"/></linearGradient></defs>
            <rect x="1" y="1" width="30" height="30" rx="9" fill="url(#nav-brand)"/>
            <path d="M10 21.5 16 9l6 12.5" fill="none" stroke="#04070F" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/>
          </svg>
          <span>Vantage</span>
        </a>
        <button class="iv-navbar__toggle" type="button" aria-expanded="false" aria-controls="site-nav" hidden>
          <span class="iv-u-sr-only">Menu</span>
          <span class="iv-navbar__burger" aria-hidden="true"></span>
        </button>
        <div class="iv-navbar__panel" id="site-nav">
          <nav class="iv-navbar__nav" aria-label="Main">
            <ul class="iv-navbar__links">
              <li><a class="iv-navbar__link" href="#nav-note" aria-current="page">Product</a></li>
              <li><a class="iv-navbar__link" href="#nav-scroll">Pricing</a></li>
              <li><a class="iv-navbar__link" href="#nav-scroll">Docs</a></li>
              <li><a class="iv-navbar__link" href="#nav-scroll">Changelog</a></li>
              <li><a class="iv-navbar__link" href="#nav-note">Support</a></li>
            </ul>
          </nav>
          <div class="iv-navbar__actions">
            <a class="iv-button iv-button--ghost iv-button--sm" href="#nav-note">Sign in</a>
            <a class="iv-button iv-button--primary iv-button--sm" href="#nav-note">Get started</a>
          </div>
        </div>
      </div>
    </header>
    <p id="nav-note">Sample header, not a real site: every link above points inside this page, nothing is signed in and nothing is bought. The header is sticky, so it condenses once the page scrolls past 24 pixels. Below the <code>lg</code> breakpoint the panel is served open and stacked; with JavaScript the burger appears and folds it.</p>
    <!-- The filler is a screen and a half tall on purpose: a sticky header needs something to scroll over. -->
    <section id="nav-scroll" class="iv-stack" style="min-block-size: 150vh">
      <h2>Room to scroll</h2>
      <p>The text below exists so the condensed state can be seen: it has no meaning of its own. Scroll down and the bar loses height, takes a glass background, an ambient shadow and the conductive rule along its bottom edge.</p>
      <p>The brand and the links keep their size; only the bar's height and its surface change, so nothing jumps under the pointer. The underline of a link grows from the centre on hover and on keyboard focus, and the current page keeps it drawn.</p>
      <p>On a narrow screen the panel folds. Opening it turns the burger into a cross, the panel slides in from above and its height is capped to the viewport minus the bar, so a long menu scrolls inside itself instead of pushing the page.</p>
      <p>Escape closes the panel and returns the focus to the burger, a click outside closes it too, and crossing the breakpoint closes it and hands the layout back to the bar.</p>
      <p>Nothing here is fetched, stored or sent. The fixture is one header and this filler.</p>
      <p>Last paragraph of the filler, so the page is taller than the viewport at every width tested.</p>
    </section>
    // data-iv-component="navbar"
    {
      sticky: true,
    }
    Cómo leer esta página

    Cada cabecera de abajo funciona en una página propia, embebida aquí: la barra se fija, se condensa y se pliega contra esa página, no contra este artículo. Desplázate dentro de un escenario para ver la barra sostenerse, cambia su ancho a 390 para verla plegarse, o ábrela sola desde su barra de controles.

    Un megamenú dentro del panel

    Un megamenú puede vivir dentro de iv-navbar__panel. Desde el punto de ruptura lg hacia arriba sus paneles flotan bajo toda la barra; por debajo, la cabecera se pliega y esos mismos paneles se comportan como un acordeón dentro de ella. Pasa data-iv-overlay="false" al menú alojado: dentro de una cabecera la barra ya es la superficie elevada, y un velo por debajo oscurecería la propia cabecera.

    Cabecera con megamenúfixtures/navbar/megamenu.htmlAbrir sola — Cabecera con megamenú
    <header class="iv-navbar" data-iv-component="navbar" data-iv-sticky="true">
      <div class="iv-navbar__inner">
        <a class="iv-navbar__brand" href="#nav-mm-note">
          <svg viewBox="0 0 32 32" aria-hidden="true" focusable="false">
            <defs><linearGradient id="nav-mm-brand" x1="0" y1="32" x2="32" y2="0" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0B6B8A"/><stop offset="1" stop-color="#73DFFF"/></linearGradient></defs>
            <circle cx="16" cy="16" r="15" fill="url(#nav-mm-brand)"/>
            <path d="M9 16h14M16 9v14" stroke="#04070F" stroke-width="2.6" stroke-linecap="round"/>
          </svg>
          <span>Vantage</span>
        </a>
        <button class="iv-navbar__toggle" type="button" aria-expanded="false" aria-controls="mega-nav" hidden>
          <span class="iv-u-sr-only">Menu</span>
          <span class="iv-navbar__burger" aria-hidden="true"></span>
        </button>
        <div class="iv-navbar__panel" id="mega-nav">
          <nav class="iv-megamenu" data-iv-component="megamenu" data-iv-overlay="false" style="--iv-megamenu-width: min(56rem, 100vw - 2rem)" aria-label="Main. Every section, count and figure below is made up for this demo.">
            <ul class="iv-megamenu__list">
              <li class="iv-megamenu__item">
                <a class="iv-megamenu__link" href="#nav-mm-note">Platform</a>
                <button class="iv-megamenu__toggle" type="button" aria-expanded="false" aria-controls="nav-mm-platform" hidden><span class="iv-u-sr-only">Open Platform</span></button>
                <section class="iv-megamenu__panel" id="nav-mm-platform" aria-labelledby="nav-mm-platform-title">
                  <header class="iv-megamenu__head">
                    <p class="iv-megamenu__overline">Explore the platform</p>
                    <h2 class="iv-megamenu__title" id="nav-mm-platform-title">Platform <span class="iv-megamenu__count">24 parts</span></h2>
                    <p class="iv-megamenu__tagline">Made-up sections, no catalogue behind them.</p>
                    <button class="iv-megamenu__close" type="button" aria-label="Close Platform" hidden></button>
                  </header>
                  <div class="iv-megamenu__body">
                    <aside class="iv-megamenu__directory">
                      <h3 class="iv-megamenu__heading">Where to start</h3>
                      <ul class="iv-megamenu__dirlist">
                        <li><a href="#nav-mm-note"><span>Components</span><small>24</small></a></li>
                        <li><a href="#nav-mm-note"><span>Tokens</span><small>133</small></a></li>
                        <li><a href="#nav-mm-note"><span>Themes</span><small>4</small></a></li>
                        <li><a href="#nav-mm-note"><span>Layouts</span><small>9</small></a></li>
                      </ul>
                      <a class="iv-megamenu__all" href="#nav-mm-note">Browse the sample</a>
                    </aside>
                    <div class="iv-megamenu__discover">
                      <div class="iv-megamenu__tabs" role="tablist" aria-label="Platform selections">
                        <a class="iv-megamenu__tab" role="tab" id="nav-mm-platform-tab-0" href="#nav-mm-platform-set-0" aria-selected="true">Build</a>
                        <a class="iv-megamenu__tab" role="tab" id="nav-mm-platform-tab-1" href="#nav-mm-platform-set-1" aria-selected="false">Ship</a>
                      </div>
                      <div class="iv-megamenu__set" id="nav-mm-platform-set-0" role="tabpanel" aria-labelledby="nav-mm-platform-tab-0">
                        <ul class="iv-megamenu__cards">
                          <li><a class="iv-megamenu__card" href="#nav-mm-note">
                            <span class="iv-megamenu__art"><svg viewBox="0 0 320 200" aria-hidden="true" focusable="false" preserveAspectRatio="xMidYMid slice"><defs><linearGradient id="nmm1" x1="0" y1="0" x2="320" y2="200" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#171A45"/><stop offset="1" stop-color="#04070F"/></linearGradient></defs><rect width="320" height="200" fill="url(#nmm1)"/><circle cx="160" cy="100" r="58" fill="none" stroke="#8B95FF" stroke-opacity=".7" stroke-width="3"/><circle cx="160" cy="100" r="22" fill="#8B95FF" fill-opacity=".3"/></svg><span class="iv-megamenu__rank" aria-hidden="true">01</span><span class="iv-megamenu__arrow" aria-hidden="true"></span></span>
                            <span class="iv-megamenu__name">Components</span>
                            <span class="iv-megamenu__meta">24 parts</span>
                          </a></li>
                          <li><a class="iv-megamenu__card" href="#nav-mm-note">
                            <span class="iv-megamenu__art"><svg viewBox="0 0 320 200" aria-hidden="true" focusable="false" preserveAspectRatio="xMidYMid slice"><defs><linearGradient id="nmm2" x1="0" y1="0" x2="320" y2="200" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0C1330"/><stop offset="1" stop-color="#2266D8"/></linearGradient></defs><rect width="320" height="200" fill="url(#nmm2)"/><path d="M-10 170 90 92l70 52 80-66 100 74v50H-10z" fill="#04070F" fill-opacity=".7"/><circle cx="246" cy="48" r="26" fill="#B3D6FF" fill-opacity=".85"/></svg><span class="iv-megamenu__rank" aria-hidden="true">02</span><span class="iv-megamenu__arrow" aria-hidden="true"></span></span>
                            <span class="iv-megamenu__name">Tokens</span>
                            <span class="iv-megamenu__meta">133 values</span>
                          </a></li>
                          <li><a class="iv-megamenu__card" href="#nav-mm-note">
                            <span class="iv-megamenu__art"><svg viewBox="0 0 320 200" aria-hidden="true" focusable="false" preserveAspectRatio="xMidYMid slice"><defs><linearGradient id="nmm3" x1="0" y1="0" x2="320" y2="200" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#2266D8"/><stop offset="1" stop-color="#0C1330"/></linearGradient></defs><rect width="320" height="200" fill="url(#nmm3)"/><path d="M16 200 160 24l144 176z" fill="#8FE3FF" fill-opacity=".24"/><path d="M108 200 160 120l52 80z" fill="#F5F7FC" fill-opacity=".55"/></svg><span class="iv-megamenu__rank" aria-hidden="true">03</span><span class="iv-megamenu__arrow" aria-hidden="true"></span></span>
                            <span class="iv-megamenu__name">Themes</span>
                            <span class="iv-megamenu__meta">4 presets</span>
                          </a></li>
                        </ul>
                      </div>
                      <div class="iv-megamenu__set" id="nav-mm-platform-set-1" role="tabpanel" aria-labelledby="nav-mm-platform-tab-1" hidden>
                        <ul class="iv-megamenu__cards">
                          <li><a class="iv-megamenu__card" href="#nav-mm-note">
                            <span class="iv-megamenu__art"><svg viewBox="0 0 320 200" aria-hidden="true" focusable="false" preserveAspectRatio="xMidYMid slice"><defs><linearGradient id="nmm4" x1="0" y1="0" x2="320" y2="200" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#262C6E"/><stop offset="1" stop-color="#04070F"/></linearGradient></defs><rect width="320" height="200" fill="url(#nmm4)"/><rect x="56" y="44" width="208" height="112" rx="10" fill="none" stroke="#FF9AA4" stroke-opacity=".6" stroke-width="3"/><path d="M88 124h64M88 100h144M88 76h104" stroke="#FF9AA4" stroke-opacity=".65" stroke-width="6" stroke-linecap="round"/></svg><span class="iv-megamenu__rank" aria-hidden="true">01</span><span class="iv-megamenu__arrow" aria-hidden="true"></span></span>
                            <span class="iv-megamenu__name">Bundles</span>
                            <span class="iv-megamenu__meta">2 entries</span>
                          </a></li>
                          <li><a class="iv-megamenu__card" href="#nav-mm-note">
                            <span class="iv-megamenu__art"><svg viewBox="0 0 320 200" aria-hidden="true" focusable="false" preserveAspectRatio="xMidYMid slice"><defs><linearGradient id="nmm5" x1="0" y1="0" x2="320" y2="200" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#094D63"/><stop offset="1" stop-color="#04070F"/></linearGradient></defs><rect width="320" height="200" fill="url(#nmm5)"/><circle cx="160" cy="100" r="58" fill="none" stroke="#73DFFF" stroke-opacity=".7" stroke-width="3"/><circle cx="160" cy="100" r="22" fill="#73DFFF" fill-opacity=".3"/></svg><span class="iv-megamenu__rank" aria-hidden="true">02</span><span class="iv-megamenu__arrow" aria-hidden="true"></span></span>
                            <span class="iv-megamenu__name">Budgets</span>
                            <span class="iv-megamenu__meta">2 ceilings</span>
                          </a></li>
                          <li><a class="iv-megamenu__card" href="#nav-mm-note">
                            <span class="iv-megamenu__art"><svg viewBox="0 0 320 200" aria-hidden="true" focusable="false" preserveAspectRatio="xMidYMid slice"><defs><linearGradient id="nmm6" x1="0" y1="0" x2="320" y2="200" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0C1330"/><stop offset="1" stop-color="#4F5BE6"/></linearGradient></defs><rect width="320" height="200" fill="url(#nmm6)"/><path d="M-10 170 90 92l70 52 80-66 100 74v50H-10z" fill="#04070F" fill-opacity=".7"/><circle cx="246" cy="48" r="26" fill="#C2C8FF" fill-opacity=".85"/></svg><span class="iv-megamenu__rank" aria-hidden="true">03</span><span class="iv-megamenu__arrow" aria-hidden="true"></span></span>
                            <span class="iv-megamenu__name">Checks</span>
                            <span class="iv-megamenu__meta">3 engines</span>
                          </a></li>
                        </ul>
                      </div>
                    </div>
                  </div>
                  <footer class="iv-megamenu__foot">
                    <span class="iv-megamenu__crumb">Vantage <b aria-hidden="true">/</b> Platform</span>
                    <a class="iv-megamenu__foot-link" href="#nav-mm-note">Open the sample</a>
                    <p class="iv-megamenu__status" aria-hidden="true"><span class="iv-megamenu__prompt">vantage:~$</span><span class="iv-megamenu__cmd">ls /platform</span><span class="iv-megamenu__caret-blink"></span><span class="iv-megamenu__hint">Esc to close</span></p>
                  </footer>
                </section>
              </li>
              <li class="iv-megamenu__item">
                <a class="iv-megamenu__link" href="#nav-mm-note">Resources</a>
                <button class="iv-megamenu__toggle" type="button" aria-expanded="false" aria-controls="nav-mm-resources" hidden><span class="iv-u-sr-only">Open Resources</span></button>
                <section class="iv-megamenu__panel" id="nav-mm-resources" aria-labelledby="nav-mm-resources-title">
                  <header class="iv-megamenu__head">
                    <p class="iv-megamenu__overline">Explore the library</p>
                    <h2 class="iv-megamenu__title" id="nav-mm-resources-title">Resources <span class="iv-megamenu__count">38 pages</span></h2>
                    <p class="iv-megamenu__tagline">Fictional library, fictional dates.</p>
                    <button class="iv-megamenu__close" type="button" aria-label="Close Resources" hidden></button>
                  </header>
                  <div class="iv-megamenu__body">
                    <aside class="iv-megamenu__directory">
                      <h3 class="iv-megamenu__heading">Where to start</h3>
                      <ul class="iv-megamenu__dirlist">
                        <li><a href="#nav-mm-note"><span>Guides</span><small>12</small></a></li>
                        <li><a href="#nav-mm-note"><span>Recipes</span><small>5</small></a></li>
                        <li><a href="#nav-mm-note"><span>Field notes</span><small>21</small></a></li>
                      </ul>
                      <a class="iv-megamenu__all" href="#nav-mm-note">Browse the sample</a>
                    </aside>
                    <div class="iv-megamenu__discover">
                      <div class="iv-megamenu__tabs" role="tablist" aria-label="Resources selections">
                        <a class="iv-megamenu__tab" role="tab" id="nav-mm-resources-tab-0" href="#nav-mm-resources-set-0" aria-selected="true">Learn</a>
                        <a class="iv-megamenu__tab" role="tab" id="nav-mm-resources-tab-1" href="#nav-mm-resources-set-1" aria-selected="false">Watch</a>
                      </div>
                      <div class="iv-megamenu__set" id="nav-mm-resources-set-0" role="tabpanel" aria-labelledby="nav-mm-resources-tab-0">
                        <ul class="iv-megamenu__cards">
                          <li><a class="iv-megamenu__card" href="#nav-mm-note">
                            <span class="iv-megamenu__art"><svg viewBox="0 0 320 200" aria-hidden="true" focusable="false" preserveAspectRatio="xMidYMid slice"><defs><linearGradient id="nmm7" x1="0" y1="0" x2="320" y2="200" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#2266D8"/><stop offset="1" stop-color="#0F1D4D"/></linearGradient></defs><rect width="320" height="200" fill="url(#nmm7)"/><path d="M16 200 160 24l144 176z" fill="#66B1FF" fill-opacity=".24"/><path d="M108 200 160 120l52 80z" fill="#EAF4FF" fill-opacity=".55"/></svg><span class="iv-megamenu__rank" aria-hidden="true">01</span><span class="iv-megamenu__arrow" aria-hidden="true"></span></span>
                            <span class="iv-megamenu__name">Guides</span>
                            <span class="iv-megamenu__meta">12 pages</span>
                          </a></li>
                          <li><a class="iv-megamenu__card" href="#nav-mm-note">
                            <span class="iv-megamenu__art"><svg viewBox="0 0 320 200" aria-hidden="true" focusable="false" preserveAspectRatio="xMidYMid slice"><defs><linearGradient id="nmm8" x1="0" y1="0" x2="320" y2="200" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#1C2544"/><stop offset="1" stop-color="#04070F"/></linearGradient></defs><rect width="320" height="200" fill="url(#nmm8)"/><rect x="56" y="44" width="208" height="112" rx="10" fill="none" stroke="#8FE3FF" stroke-opacity=".6" stroke-width="3"/><path d="M88 124h64M88 100h144M88 76h104" stroke="#D6E9FF" stroke-opacity=".65" stroke-width="6" stroke-linecap="round"/></svg><span class="iv-megamenu__rank" aria-hidden="true">02</span><span class="iv-megamenu__arrow" aria-hidden="true"></span></span>
                            <span class="iv-megamenu__name">Recipes</span>
                            <span class="iv-megamenu__meta">5 samples</span>
                          </a></li>
                          <li><a class="iv-megamenu__card" href="#nav-mm-note">
                            <span class="iv-megamenu__art"><svg viewBox="0 0 320 200" aria-hidden="true" focusable="false" preserveAspectRatio="xMidYMid slice"><defs><linearGradient id="nmm9" x1="0" y1="0" x2="320" y2="200" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0F1D4D"/><stop offset="1" stop-color="#04070F"/></linearGradient></defs><rect width="320" height="200" fill="url(#nmm9)"/><circle cx="160" cy="100" r="58" fill="none" stroke="#FF9AA4" stroke-opacity=".7" stroke-width="3"/><circle cx="160" cy="100" r="22" fill="#FF9AA4" fill-opacity=".3"/></svg><span class="iv-megamenu__rank" aria-hidden="true">03</span><span class="iv-megamenu__arrow" aria-hidden="true"></span></span>
                            <span class="iv-megamenu__name">Field notes</span>
                            <span class="iv-megamenu__meta">21 posts</span>
                          </a></li>
                        </ul>
                      </div>
                      <div class="iv-megamenu__set" id="nav-mm-resources-set-1" role="tabpanel" aria-labelledby="nav-mm-resources-tab-1" hidden>
                        <ul class="iv-megamenu__cards">
                          <li><a class="iv-megamenu__card" href="#nav-mm-note">
                            <span class="iv-megamenu__art"><svg viewBox="0 0 320 200" aria-hidden="true" focusable="false" preserveAspectRatio="xMidYMid slice"><defs><linearGradient id="nmm10" x1="0" y1="0" x2="320" y2="200" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0C1330"/><stop offset="1" stop-color="#17AAD6"/></linearGradient></defs><rect width="320" height="200" fill="url(#nmm10)"/><path d="M-10 170 90 92l70 52 80-66 100 74v50H-10z" fill="#04070F" fill-opacity=".7"/><circle cx="246" cy="48" r="26" fill="#A6EFFF" fill-opacity=".85"/></svg><span class="iv-megamenu__rank" aria-hidden="true">01</span><span class="iv-megamenu__arrow" aria-hidden="true"></span></span>
                            <span class="iv-megamenu__name">Walkthroughs</span>
                            <span class="iv-megamenu__meta">7 clips</span>
                          </a></li>
                          <li><a class="iv-megamenu__card" href="#nav-mm-note">
                            <span class="iv-megamenu__art"><svg viewBox="0 0 320 200" aria-hidden="true" focusable="false" preserveAspectRatio="xMidYMid slice"><defs><linearGradient id="nmm11" x1="0" y1="0" x2="320" y2="200" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#2266D8"/><stop offset="1" stop-color="#171A45"/></linearGradient></defs><rect width="320" height="200" fill="url(#nmm11)"/><path d="M16 200 160 24l144 176z" fill="#8B95FF" fill-opacity=".24"/><path d="M108 200 160 120l52 80z" fill="#EEF0FF" fill-opacity=".55"/></svg><span class="iv-megamenu__rank" aria-hidden="true">02</span><span class="iv-megamenu__arrow" aria-hidden="true"></span></span>
                            <span class="iv-megamenu__name">Sessions</span>
                            <span class="iv-megamenu__meta">4 clips</span>
                          </a></li>
                          <li><a class="iv-megamenu__card" href="#nav-mm-note">
                            <span class="iv-megamenu__art"><svg viewBox="0 0 320 200" aria-hidden="true" focusable="false" preserveAspectRatio="xMidYMid slice"><defs><linearGradient id="nmm12" x1="0" y1="0" x2="320" y2="200" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#172F7A"/><stop offset="1" stop-color="#04070F"/></linearGradient></defs><rect width="320" height="200" fill="url(#nmm12)"/><rect x="56" y="44" width="208" height="112" rx="10" fill="none" stroke="#66B1FF" stroke-opacity=".6" stroke-width="3"/><path d="M88 124h64M88 100h144M88 76h104" stroke="#B3D6FF" stroke-opacity=".65" stroke-width="6" stroke-linecap="round"/></svg><span class="iv-megamenu__rank" aria-hidden="true">03</span><span class="iv-megamenu__arrow" aria-hidden="true"></span></span>
                            <span class="iv-megamenu__name">Talks</span>
                            <span class="iv-megamenu__meta">3 clips</span>
                          </a></li>
                        </ul>
                      </div>
                    </div>
                  </div>
                  <footer class="iv-megamenu__foot">
                    <span class="iv-megamenu__crumb">Vantage <b aria-hidden="true">/</b> Resources</span>
                    <a class="iv-megamenu__foot-link" href="#nav-mm-note">Open the sample</a>
                    <p class="iv-megamenu__status" aria-hidden="true"><span class="iv-megamenu__prompt">vantage:~$</span><span class="iv-megamenu__cmd">ls /resources</span><span class="iv-megamenu__caret-blink"></span><span class="iv-megamenu__hint">Esc to close</span></p>
                  </footer>
                </section>
              </li>
              <li class="iv-megamenu__item">
                <a class="iv-megamenu__link" href="#nav-mm-note">Pricing</a>
              </li>
            </ul>
          </nav>
          <div class="iv-navbar__actions">
            <a class="iv-button iv-button--ghost iv-button--sm" href="#nav-mm-note">Sign in</a>
            <a class="iv-button iv-button--primary iv-button--sm" href="#nav-mm-note">Get started</a>
          </div>
        </div>
      </div>
    </header>
    <p id="nav-mm-note">Sample header with a megamenu inside its panel: every link points to this note, nothing is signed in and nothing is bought. The panel is capped at <code>56rem</code> through <code>--iv-megamenu-width</code>, because inside a header the bar is not centred on the page and a full-width panel would hang off the viewport. The menu runs without its page overlay: inside a header the bar is already the elevated surface, and a scrim under it would dim the header itself. From the <code>lg</code> breakpoint upwards the megamenu panels float under the whole bar; below it, the navbar folds and the same panels behave as an accordion inside it.</p>
    <!-- The filler is a screen and a half tall on purpose: a sticky header needs something to scroll over. -->
    <section id="nav-mm-scroll" class="iv-stack" style="min-block-size: 150vh">
      <h2>Room to scroll</h2>
      <p>Filler text, so the sticky header can be seen condensing while a megamenu panel is open. The header sits above the megamenu overlay on purpose: the bar you are reading from must stay legible while the page behind it dims.</p>
      <p>Nothing on this page is fetched from anywhere.</p>
      <p>Last paragraph of the filler.</p>
    </section>
    .iv-root {
      --iv-megamenu-width: min(56rem, 100vw - 2rem);
    }
    // data-iv-component="navbar"
    // data-iv-component="megamenu"
    {
      sticky: true,
      overlay: false,
    }

    Transparente sobre una portada

    iv-navbar--transparent quita el fondo y toma texto claro mientras la cabecera está sobre un hero; en cuanto se condensa o abre su panel, vuelven la superficie y los colores de la página, porque una barra transparente sobre contenido no se lee. iv-navbar--glass mantiene la superficie de cristal en cualquier posición de scroll, y iv-navbar--center centra los enlaces y deja las acciones al final.

    Transparente sobre una portadafixtures/navbar/transparent.htmlAbrir sola — Transparente sobre una portada
    <header class="iv-navbar iv-navbar--transparent" data-iv-component="navbar" data-iv-sticky="true">
      <div class="iv-navbar__inner">
        <a class="iv-navbar__brand" href="#nav-t-note">
          <svg viewBox="0 0 32 32" aria-hidden="true" focusable="false">
            <rect x="1" y="1" width="30" height="30" rx="9" fill="none" stroke="currentColor" stroke-width="2"/>
            <path d="M10 21.5 16 9l6 12.5" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/>
          </svg>
          <span>Vantage</span>
        </a>
        <button class="iv-navbar__toggle" type="button" aria-expanded="false" aria-controls="cover-nav" hidden>
          <span class="iv-u-sr-only">Menu</span>
          <span class="iv-navbar__burger" aria-hidden="true"></span>
        </button>
        <div class="iv-navbar__panel" id="cover-nav">
          <nav class="iv-navbar__nav" aria-label="Main">
            <ul class="iv-navbar__links">
              <li><a class="iv-navbar__link" href="#nav-t-note" aria-current="page">Cover</a></li>
              <li><a class="iv-navbar__link" href="#nav-t-scroll">Story</a></li>
              <li><a class="iv-navbar__link" href="#nav-t-scroll">Cast</a></li>
              <li><a class="iv-navbar__link" href="#nav-t-note">Press</a></li>
            </ul>
          </nav>
          <div class="iv-navbar__actions">
            <a class="iv-button iv-button--primary iv-button--sm" href="#nav-t-scroll">Watch the sample</a>
          </div>
        </div>
      </div>
    </header>
    <!-- The cover slides under the transparent bar: the header is 4rem tall, so the hero starts 4rem higher and pads its own content back down. -->
    <section class="iv-hero iv-hero--cinematic iv-hero--center" id="nav-t-cover" style="margin-block-start: -4rem; padding-block-start: 6rem">
      <div class="iv-hero__media iv-texture-mesh" aria-hidden="true"></div>
      <div class="iv-hero__scrim" aria-hidden="true"></div>
      <div class="iv-hero__content">
        <p class="iv-hero__kicker">Sample fixture, not a real film</p>
        <h2 class="iv-hero__title">A bar that stays out of the way</h2>
        <p class="iv-hero__lead">Made-up copy, for the fixture only. The header has no ground of its own over the cover and borrows its light text; the moment the page scrolls it condenses, takes a glass surface and the text returns to the page colours. The cover itself is a gradient mesh: no photograph ships inside the package.</p>
        <div class="iv-hero__actions">
          <a class="iv-button iv-button--primary iv-button--lg" href="#nav-t-scroll">Read the sample notes</a>
        </div>
      </div>
    </section>
    <p id="nav-t-note">Sample cover, not a real product: every link points inside this page and nothing is played, bought or sent.</p>
    <section id="nav-t-scroll" class="iv-stack">
      <h2>Sample notes</h2>
      <p>Filler text so the page scrolls and the transparent header can be seen condensing. Once condensed it is no longer transparent: a transparent bar over page content would be unreadable, so the surface and the text colours come back.</p>
      <p>Unfolding the panel does the same thing for the same reason: an open menu needs a readable ground, whatever is behind it.</p>
      <p>Nothing on this page is fetched from anywhere. The cover is two gradients and a scrim.</p>
      <p>Last paragraph of the filler.</p>
    </section>
    // data-iv-component="navbar"
    {
      sticky: true,
    }

    Opciones

    OpciónAtributoPor defectoEfecto
    collapseBelowdata-iv-collapse-belowlgPunto de ruptura por debajo del cual el panel se pliega tras la hamburguesa. none no pliega nunca.
    stickydata-iv-stickyfalseMantiene la cabecera arriba y la condensa al hacer scroll.
    condenseAtdata-iv-condense-at24Píxeles de scroll antes de que data-iv-condensed aparezca en la cabecera.
    hideOnScrolldata-iv-hide-on-scrollfalseRetira la barra al bajar y la devuelve al subir. Nunca con el panel abierto ni con el foco dentro.
    closeOnOutsidedata-iv-close-on-outsidetrueUn clic fuera de la cabecera cierra el panel abierto.

    Métodos y eventos

    open(), close(reason), toggle(), destroy(); lectura de isOpen y isCondensed. Por encima del punto de plegado open() no hace nada e isOpen se queda en false: no hay nada plegado que desplegar.

    EventoCuándodetail
    iv:openiv:openedel panel plegado se despliega; el primero es cancelablereason, trigger
    iv:closeiv:closedel panel vuelve a plegarsereason: trigger, escape, external, api o viewport
    iv:condensela cabecera entra o sale del estado condensadocondensed

    Teclado y tecnología asistiva

    La cabecera es una región <header> y los enlaces viven en un <nav> con su propia etiqueta. La hamburguesa es un botón de verdad con nombre para lectores de pantalla, aria-expanded y aria-controls; Enter y Espacio funcionan sobre ella, Escape cierra el panel y devuelve el foco al botón, y Tab recorre el panel abierto en el orden del documento. La página actual lleva aria-current="page". No se usan roles de menú: esto son enlaces, no un menú. Cruzar el punto de ruptura hacia arriba cierra el panel y devuelve el mando a la barra.

    Sin JavaScript

    Todo sigue al alcance. Por encima de collapseBelow el panel es una barra en línea con la marca; por debajo llega abierto y apilado, y la hamburguesa se queda hidden porque no tendría nada que alternar. El plegado solo ocurre bajo [data-iv-js], así que un script que no cargue no puede esconder un menú. La cabecera pegajosa la hace el CSS y tampoco necesita script; solo lo necesitan condensarse, retirarse al bajar y el panel plegado.

    Plegar sin salto de maqueta

    El panel se sirve abierto e init lo pliega, lo que desplaza toda la página hacia abajo en un móvil cuando arranca el script. Para plegarlo desde el primer pintado, marca la raíz antes de la hoja con una línea en <head>: <script>document.documentElement.setAttribute("data-iv-js", "")</script>. Por debajo de lg el panel arranca plegado y el toggle aparece cuando init lo muestra; desde lg la barra va en línea. Tan pronto solo se conoce el breakpoint por defecto. Si el script pudiera no cargar, no pongas la marca: un panel plegado sin toggle es peor que un salto. La receta showcase la usa.

    Tokens y locales

    LocalPor defectoQué mueve
    --iv-navbar-height4remAltura de la barra en reposo.
    --iv-navbar-height-condensed3.25remAltura una vez pasado condenseAt.
    --iv-navbar-bgvar(--iv-color-bg)Superficie de la barra.
    --iv-navbar-maxvar(--iv-container-max)Ancho al que se centra la fila interior.
    --iv-navbar-gapvar(--iv-space-5)Separación entre marca, navegación y acciones.
    --iv-navbar-z150Orden de apilado frente a la página.

    El estado vive en atributos para que el CSS pueda leerlo: data-iv-collapsible mientras el ancho está por debajo del punto de ruptura, data-iv-open en el panel desplegado, data-iv-condensed tras el scroll y data-iv-hidden en una barra retirada. La barra condensada toma --iv-shadow-ambient y un fondo de cristal; con movimiento reducido nada se desplaza, pero data-iv-hidden sigue apartando la barra porque eso es estado, no adorno.

    Errores frecuentes

    • Servir el panel cerrado. Sin el script nada lo abriría; el marcado tiene que llegar usable y plegarse después.
    • Usar la barra como panel lateral. Si la navegación debe cubrir la página y atrapar el foco, eso es drawer.
    • Combinar hideOnScroll con contenido que salta a anclas: la barra escribe scroll-padding-block-start mientras es pegajosa, pero una cabecera que aparece y desaparece cuesta orientación.
    • Un megamenú alojado con su superposición encendida: el velo oscurece la propia barra desde la que estás leyendo.