ComponentesComponents

Barra de navegaciónNavigation bar

Cabecera con logo, enlaces y acciones. En móvil, los enlaces van a un menú.Header with logo, links and actions. On mobile, links move into a menu.

DiseñoDesign: Origin UI (MIT) · comp-577.tsx, navigation-menu.tsxMITambos · densidaddensity media · sobriaMarkdownJSON

CódigoCode

<header class="c-navbar">
  <div class="c-navbar__inner">
    <div class="c-navbar__start">
      <button class="c-btn c-btn--ghost c-btn--icon c-navbar__toggle" type="button" aria-label="Menú" aria-expanded="false" aria-controls="navbar-mobile" data-c-navbar>
        <svg class="c-navbar__burger" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M4 12L20 12"/><path d="M4 12H20"/><path d="M4 12H20"/></svg>
      </button>
      <div class="c-navbar__main">
        <a class="c-navbar__logo" href="#" aria-label="Inicio"><svg viewBox="0 0 33 33" fill="currentColor" aria-hidden="true"><path d="M20.46 1.766 17.303.923l-2.66 9.896-2.403-8.934-3.157.843 2.595 9.652-6.464-6.442-2.311 2.304 7.09 7.066-8.83-2.358-.846 3.146 9.648 2.577a6.516 6.516 0 0 1-.169-1.478c0-3.598 2.927-6.515 6.537-6.515s6.537 2.917 6.537 6.515c0 .505-.057.997-.167 1.468l8.768 2.342.846-3.147-9.686-2.586 8.83-2.358-.845-3.147-9.686 2.587 6.464-6.442-2.311-2.304-6.992 6.969 2.369-8.81Z"/><path d="M22.695 18.7a6.495 6.495 0 0 1-1.626 2.986l6.352 6.33 2.31-2.303-7.036-7.013ZM21.005 21.752a6.538 6.538 0 0 1-2.922 1.722l2.312 8.596 3.157-.843-2.547-9.475ZM17.965 23.505a6.569 6.569 0 0 1-1.632.205 6.566 6.566 0 0 1-1.743-.235l-2.314 8.605 3.157.843 2.532-9.418ZM14.478 23.444a6.54 6.54 0 0 1-2.87-1.747l-6.367 6.346 2.31 2.303 6.927-6.902ZM11.555 21.64a6.492 6.492 0 0 1-1.585-2.948L1.173 21.04l.846 3.146 9.536-2.546Z"/></svg></a>
        <nav aria-label="Principal">
          <ul class="c-navbar__list">
            <li><a class="c-navbar__link" href="#" aria-current="page">Inicio</a></li>
            <li><a class="c-navbar__link" href="#features">Funciones</a></li>
            <li><a class="c-navbar__link" href="#pricing">Precios</a></li>
            <li><a class="c-navbar__link" href="#about">Nosotros</a></li>
          </ul>
        </nav>
      </div>
    </div>
    <div class="c-navbar__end">
      <a class="c-btn c-btn--ghost c-btn--sm" href="#login">Entrar</a>
      <a class="c-btn c-btn--primary c-btn--sm" href="#signup">Empezar</a>
    </div>
  </div>
  <nav class="c-navbar__mobile" id="navbar-mobile" popover aria-label="Principal (móvil)">
    <ul>
      <li><a class="c-navbar__mobile-link" href="#" aria-current="page">Inicio</a></li>
      <li><a class="c-navbar__mobile-link" href="#features">Funciones</a></li>
      <li><a class="c-navbar__mobile-link" href="#pricing">Precios</a></li>
      <li><a class="c-navbar__mobile-link" href="#about">Nosotros</a></li>
    </ul>
  </nav>
</header>

«Todo» trae tokens, dependencias y componente en un solo archivo, listo para abrir o dárselo a un agente.“All” bundles tokens, dependencies and the component in one file, ready to open or hand to an agent.

InstalaciónInstallation

  1. Agrega una vezAdd once tokens.css (colores, radios, tema oscuro).(colors, radii, dark theme).
  2. Agrega también:Also add: BotónButton.
  3. Copia los archivos:Copy the files: navbar.html, navbar.css, navbar.js.
  4. Para el tema oscuro, pon la claseFor the dark theme, add the class dark ento <html>.

Cuándo usarloWhen to use it

ÚsaloUse it

  • Como cabecera de cualquier sitio.
  • As the header of any site.

Mejor noAvoid

  • Con más de 6 enlaces: agrupa o usa una barra lateral.
  • With more than 6 links: group them or use a sidebar.

AccesibilidadAccessibility

navigationlinkbutton
TabRecorre enlaces y botonesMoves through links and buttons
EscCierra el menú móvilCloses the mobile menu
  • <nav> con aria-label y aria-current=page en la página actual.
  • El menú móvil es un popover nativo: cierra con Esc o clic fuera y devuelve el foco al botón.
  • Nada de role=menu: son enlaces de navegación.
  • <nav> with aria-label and aria-current=page on the current page.
  • The mobile menu is a native popover: closes with Esc or outside click and returns focus.
  • No role=menu: these are navigation links.

Cómo probarloHow to test it

  • En móvil, abre el menú y pulsa Esc: el foco vuelve al botón.
  • On mobile, open the menu and press Esc: focus returns to the button.

CréditosCredits