Aller au contenu

🪧 En-têtes (headers)Gratuit · 0 NahnahPar NAHNAH AI

En-tête tiroir latéral

Bouton menu toujours visible qui ouvre un tiroir latéral (boîte de dialogue accessible : focus piégé, Échap, clic sur le fond pour fermer).

Aperçu en direct

Données de démonstration (produits, menus, textes d’exemple) : dans ta boutique, ce sont les tiennes.

Photos : Unsplash / Pexels (exemples de l’aperçu, jamais inclus dans le code).

Code à copier

Fichier complet sections/nahnah-menu-tiroir-lateral.liquid (Liquid, CSS et JS inclus).

{%- comment -%} NAHNAH AI · En-tête tiroir latéral (bibliothèque Sections & effets) {%- endcomment -%}
<nn-menu-tiroir-lateral class="nn-menu-tiroir-lateral" style="--nn-mh: {{ section.settings.marge_haut }}px; --nn-mb: {{ section.settings.marge_bas }}px; --nn-fond: {{ section.settings.couleur_fond }}; --nn-texte: {{ section.settings.couleur_texte }}; --nn-accent: {{ section.settings.couleur_accent }}; --nn-bouton: {{ section.settings.couleur_bouton }}; --nn-texte-bouton: {{ section.settings.couleur_texte_bouton }};">
  <div class="nn-menu-tiroir-lateral__barre">
    <button type="button" class="nn-menu-tiroir-lateral__ouvrir" aria-expanded="false" aria-controls="NnTiroir-{{ section.id }}" data-nn-ouvrir>
      <svg class="nn-menu-tiroir-lateral__ico" aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7h16M4 12h16M4 17h16"/></svg><span class="nn-menu-tiroir-lateral__ouvrir-texte">Menu</span>
    </button>
    <a class="nn-menu-tiroir-lateral__logo" href="{{ routes.root_url }}"><span class="nn-menu-tiroir-lateral__nom">{{ shop.name | escape }}</span></a>
    <div class="nn-menu-tiroir-lateral__icones">
      <a class="nn-menu-tiroir-lateral__icone" href="{{ routes.search_url }}" aria-label="Rechercher"><svg class="nn-menu-tiroir-lateral__ico" aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg></a>
      {%- if section.settings.compte -%}<a class="nn-menu-tiroir-lateral__icone nn-menu-tiroir-lateral__icone--compte" href="{{ routes.account_url }}" aria-label="Mon compte"><svg class="nn-menu-tiroir-lateral__ico" aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/></svg></a>{%- endif -%}
      <a class="nn-menu-tiroir-lateral__icone nn-menu-tiroir-lateral__panier" href="{{ routes.cart_url }}" aria-label="Panier : {{ cart.item_count }} article{% if cart.item_count > 1 %}s{% endif %}">
        <svg class="nn-menu-tiroir-lateral__ico" aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M5 8h14l-1.2 12.1a1 1 0 0 1-1 .9H7.2a1 1 0 0 1-1-.9L5 8z"/><path d="M9 8V7a3 3 0 0 1 6 0v1"/></svg>
        {%- if cart.item_count > 0 -%}<span class="nn-menu-tiroir-lateral__compteur" aria-hidden="true">{{ cart.item_count }}</span>{%- endif -%}
      </a>
    </div>
  </div>
  <dialog class="nn-menu-tiroir-lateral__tiroir" id="NnTiroir-{{ section.id }}" aria-label="Menu" data-nn-tiroir>
    <div class="nn-menu-tiroir-lateral__tete">
      <span class="nn-menu-tiroir-lateral__tete-titre">Menu</span>
      <button type="button" class="nn-menu-tiroir-lateral__fermer" aria-label="Fermer le menu" data-nn-fermer><svg class="nn-menu-tiroir-lateral__ico" aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M6 6l12 12M18 6 6 18"/></svg></button>
    </div>
    <nav class="nn-menu-tiroir-lateral__corps" aria-label="Menu principal">
      <ul class="nn-menu-tiroir-lateral__mob-liste" role="list">
        {%- for link in section.settings.menu.links -%}
          <li class="nn-menu-tiroir-lateral__mob-item">
            {%- if link.links != blank -%}
              <details class="nn-menu-tiroir-lateral__mob-sous" data-nn-sous>
                <summary class="nn-menu-tiroir-lateral__mob-lien">
                  <span>{{ link.title | escape }}</span>
                  <svg class="nn-menu-tiroir-lateral__chevron" aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>
                </summary>
                <ul class="nn-menu-tiroir-lateral__mob-sous-liste" role="list">
                  {%- for enfant in link.links -%}
                    <li><a class="nn-menu-tiroir-lateral__mob-sous-lien" href="{{ enfant.url }}"{% if enfant.current %} aria-current="page"{% endif %}>{{ enfant.title | escape }}</a></li>
                  {%- endfor -%}
                  <li><a class="nn-menu-tiroir-lateral__mob-sous-lien nn-menu-tiroir-lateral__mob-sous-lien--tout" href="{{ link.url }}">Tout voir : {{ link.title | escape }}</a></li>
                </ul>
              </details>
            {%- else -%}
              <a class="nn-menu-tiroir-lateral__mob-lien" href="{{ link.url }}"{% if link.current %} aria-current="page"{% endif %}>{{ link.title | escape }}</a>
            {%- endif -%}
          </li>
        {%- endfor -%}
      </ul>
      <ul class="nn-menu-tiroir-lateral__secondaire" role="list">
        <li><a href="{{ routes.search_url }}"><svg class="nn-menu-tiroir-lateral__ico" aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>Rechercher</a></li>
        {%- if section.settings.compte -%}<li><a href="{{ routes.account_url }}"><svg class="nn-menu-tiroir-lateral__ico" aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/></svg>Mon compte</a></li>{%- endif -%}
      </ul>
    </nav>
    {%- if section.settings.tiroir_texte != blank -%}
      <p class="nn-menu-tiroir-lateral__pied">{{ section.settings.tiroir_texte | escape }}</p>
    {%- endif -%}
  </dialog>
</nn-menu-tiroir-lateral>

{% schema %}
{
  "name": "En-tête tiroir latéral",
  "tag": "header",
  "class": "nn-section-menu-tiroir-lateral",
  "settings": [
    {
      "type": "link_list",
      "id": "menu",
      "label": "Menu",
      "default": "main-menu"
    },
    {
      "type": "checkbox",
      "id": "compte",
      "label": "Afficher l’icône du compte client",
      "default": true
    },
    {
      "type": "text",
      "id": "tiroir_texte",
      "label": "Texte en bas du tiroir (vide : masqué)",
      "default": "Besoin d’aide ? Écris-nous, nous répondons rapidement."
    },
    {
      "type": "header",
      "content": "Couleurs"
    },
    {
      "type": "color",
      "id": "couleur_fond",
      "label": "Fond",
      "default": "#111315"
    },
    {
      "type": "color",
      "id": "couleur_texte",
      "label": "Texte",
      "default": "#F5F5F0"
    },
    {
      "type": "color",
      "id": "couleur_accent",
      "label": "Accent",
      "default": "#F5C451"
    },
    {
      "type": "color",
      "id": "couleur_bouton",
      "label": "Bouton et pastille du panier",
      "default": "#F5C451"
    },
    {
      "type": "color",
      "id": "couleur_texte_bouton",
      "label": "Texte du bouton",
      "default": "#111315"
    },
    {
      "type": "header",
      "content": "Espacement"
    },
    {
      "type": "range",
      "id": "marge_haut",
      "label": "Marge haute",
      "min": 0,
      "max": 120,
      "step": 4,
      "unit": "px",
      "default": 0
    },
    {
      "type": "range",
      "id": "marge_bas",
      "label": "Marge basse",
      "min": 0,
      "max": 120,
      "step": 4,
      "unit": "px",
      "default": 0
    }
  ],
  "presets": [
    {
      "name": "En-tête tiroir latéral"
    }
  ]
}
{% endschema %}

{% stylesheet %}
.nn-menu-tiroir-lateral {
  position: relative;
  z-index: 20;
  display: block;
  padding: var(--nn-mh) 0 var(--nn-mb);
  background: var(--nn-fond);
  color: var(--nn-texte);
  overflow-x: clip;
}
.nn-menu-tiroir-lateral *, .nn-menu-tiroir-lateral *::before, .nn-menu-tiroir-lateral *::after { box-sizing: border-box; }
.nn-menu-tiroir-lateral :where(a, button, summary, input):focus-visible { outline: 3px solid var(--nn-accent); outline-offset: 2px; }
.nn-menu-tiroir-lateral summary { list-style: none; cursor: pointer; }
.nn-menu-tiroir-lateral summary::-webkit-details-marker { display: none; }
.nn-menu-tiroir-lateral__vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nn-menu-tiroir-lateral__logo { display: inline-flex; align-items: center; min-width: 0; min-height: 44px; color: inherit; text-decoration: none; }
.nn-menu-tiroir-lateral__logo-img { display: block; width: var(--nn-logo, 120px); max-width: 100%; height: auto; max-height: 56px; object-fit: contain; object-position: left center; }
.nn-menu-tiroir-lateral__nom { overflow: hidden; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; text-overflow: ellipsis; }
.nn-menu-tiroir-lateral__icones { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.nn-menu-tiroir-lateral__icone { position: relative; display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; color: inherit; text-decoration: none; transition: background-color 0.2s ease; }
@media (hover: hover) { .nn-menu-tiroir-lateral__icone:hover { background: color-mix(in srgb, var(--nn-texte) 8%, transparent); } }
.nn-menu-tiroir-lateral__ico { width: 22px; height: 22px; }
.nn-menu-tiroir-lateral__compteur {
  position: absolute;
  top: 3px;
  right: 1px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--nn-bouton);
  color: var(--nn-texte-bouton);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  animation: nn-menu-tiroir-lateral-compteur 0.4s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
@keyframes nn-menu-tiroir-lateral-compteur { from { transform: scale(0.4); } }
@media (max-width: 380px) { .nn-menu-tiroir-lateral__icone--compte { display: none; } }
.nn-menu-tiroir-lateral__barre { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; max-width: 1280px; min-height: 68px; margin: 0 auto; padding: 8px 16px; }
.nn-menu-tiroir-lateral__ouvrir { display: inline-flex; align-items: center; justify-self: start; gap: 10px; min-height: 44px; padding: 0 12px 0 8px; border: 0; border-radius: 999px; background: none; color: inherit; font: inherit; font-size: 14px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; transition: background-color 0.2s ease; }
@media (hover: hover) { .nn-menu-tiroir-lateral__ouvrir:hover { background: color-mix(in srgb, var(--nn-texte) 10%, transparent); } }
.nn-menu-tiroir-lateral__nom { font-size: clamp(18px, 3vw, 24px); letter-spacing: 0.04em; }
@media (max-width: 480px) { .nn-menu-tiroir-lateral__ouvrir-texte { display: none; } .nn-menu-tiroir-lateral__barre { grid-template-columns: 44px 1fr auto; } .nn-menu-tiroir-lateral__logo { justify-self: center; } }
.nn-menu-tiroir-lateral__tiroir {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(380px, 88vw);
  max-width: 88vw;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--nn-fond);
  color: var(--nn-texte);
  box-shadow: 20px 0 60px rgba(0, 0, 0, 0.4);
}
.nn-menu-tiroir-lateral__tiroir[open] { display: flex; flex-direction: column; animation: nn-menu-tiroir-lateral-entree 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes nn-menu-tiroir-lateral-entree { from { transform: translateX(-100%); } }
.nn-menu-tiroir-lateral__tiroir::backdrop { background: rgba(0, 0, 0, 0.55); }
.nn-menu-tiroir-lateral__tete { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 20px; border-bottom: 1px solid color-mix(in srgb, var(--nn-texte) 12%, transparent); }
.nn-menu-tiroir-lateral__tete-titre { font-size: 13px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--nn-accent); }
.nn-menu-tiroir-lateral__fermer { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; }
.nn-menu-tiroir-lateral__corps { flex: 1 1 auto; overflow-y: auto; padding: 8px 20px 24px; }
.nn-menu-tiroir-lateral__mob-liste { margin: 0; padding: 0; list-style: none; }
.nn-menu-tiroir-lateral__mob-item { border-bottom: 1px solid color-mix(in srgb, var(--nn-texte) 10%, transparent); }
.nn-menu-tiroir-lateral__mob-lien { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; color: inherit; font-size: 17px; font-weight: 600; text-decoration: none; }
.nn-menu-tiroir-lateral__mob-sous-liste { margin: 0 0 12px; padding: 0 0 0 14px; border-left: 2px solid var(--nn-accent); list-style: none; }
.nn-menu-tiroir-lateral__mob-sous-lien { display: flex; align-items: center; min-height: 44px; color: inherit; font-size: 16px; text-decoration: none; opacity: 0.88; }
.nn-menu-tiroir-lateral__mob-lien { font-size: 20px; }
.nn-menu-tiroir-lateral__chevron { width: 18px; height: 18px; transition: transform 0.2s ease; }
.nn-menu-tiroir-lateral__mob-sous[open] > summary .nn-menu-tiroir-lateral__chevron { transform: rotate(180deg); }
.nn-menu-tiroir-lateral__secondaire { display: grid; gap: 4px; margin: 20px 0 0; padding: 0; list-style: none; }
.nn-menu-tiroir-lateral__secondaire a { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; color: inherit; text-decoration: none; opacity: 0.85; }
.nn-menu-tiroir-lateral__pied { margin: 0; padding: 16px 20px 24px; border-top: 1px solid color-mix(in srgb, var(--nn-texte) 12%, transparent); font-size: 14px; opacity: 0.75; }
@media (prefers-reduced-motion: reduce) {
  .nn-menu-tiroir-lateral, .nn-menu-tiroir-lateral *, .nn-menu-tiroir-lateral *::before, .nn-menu-tiroir-lateral *::after {
    animation: none !important;
    transition: none !important;
  }
}
{% endstylesheet %}

{% javascript %}
if (!customElements.get("nn-menu-tiroir-lateral")) {
  // Tiroir <dialog> : showModal (focus piégé, Échap natif), fermeture au clic sur le fond, défilement de la page bloqué
  customElements.define("nn-menu-tiroir-lateral", class extends HTMLElement {
    connectedCallback() {
      if (this._pret) return;
      this._pret = true;
      var bouton = this.querySelector("[data-nn-ouvrir]");
      var tiroir = this.querySelector("[data-nn-tiroir]");
      var fermer = this.querySelector("[data-nn-fermer]");
      if (!bouton || !tiroir) return;
      var racine = document.documentElement;
      var ouvrir = function () {
        if (typeof tiroir.showModal === "function") tiroir.showModal();
        else tiroir.setAttribute("open", "");
        bouton.setAttribute("aria-expanded", "true");
        racine.style.overflow = "hidden";
      };
      var clore = function () {
        if (typeof tiroir.close === "function") tiroir.close();
        else { tiroir.removeAttribute("open"); bouton.setAttribute("aria-expanded", "false"); racine.style.overflow = ""; }
      };
      bouton.addEventListener("click", ouvrir);
      if (fermer) fermer.addEventListener("click", clore);
      tiroir.addEventListener("click", function (e) { if (e.target === tiroir) clore(); });
      tiroir.addEventListener("close", function () {
        bouton.setAttribute("aria-expanded", "false");
        racine.style.overflow = "";
        bouton.focus();
      });
    }
    disconnectedCallback() {
      document.documentElement.style.overflow = "";
    }
  });
}
{% endjavascript %}
Télécharger le fichier .liquid

Licence NAHNAH AI : utilisation libre dans tes boutiques (y compris commerciales), modification permise, revente de l’élément seul interdite.

Prompt à copier

À coller dans Claude ou ChatGPT avec le fichier téléchargé (ou le code copié) : l’assistant t’aide à l’installer et à l’adapter à ta marque.

Tu es un expert des thèmes Shopify Online Store 2.0. Aide-moi à installer puis à adapter à ma marque cet élément gratuit de la bibliothèque NAHNAH AI.

Élément : « En-tête tiroir latéral » (En-têtes (headers))
Description : Bouton menu toujours visible qui ouvre un tiroir latéral (boîte de dialogue accessible : focus piégé, Échap, clic sur le fond pour fermer).
Page de l’élément (aperçu en direct) : https://ai.nahnah.shop/bibliotheque-shopify/menu-tiroir-lateral
Fichier : nahnah-menu-tiroir-lateral.liquid (bouton « Télécharger » de la page) ou le code copié avec le bouton « Copier » : je te le joins ou je le colle après ce message.
Emplacement dans le thème : sections/nahnah-menu-tiroir-lateral.liquid (Liquid, puis {% stylesheet %} et {% javascript %}, dans ce seul fichier).

Étapes d’installation :
1. Dans Shopify : Boutique en ligne → Thèmes → bouton « … » du thème → Modifier le code.
2. Dossier « sections » → « Ajouter une section » (ou « Nouveau fichier ») → nomme-la « nahnah-menu-tiroir-lateral ».
3. Efface le contenu proposé, colle le code de l’onglet Liquid (fichier complet), puis Enregistrer.
4. Ouvre Personnaliser → Ajouter une section → choisis-la, règle les textes et les couleurs, puis Enregistrer.

Ce que j’attends de toi :
- Guide-moi pas à pas dans Shopify : Boutique en ligne → Thèmes → « … » → Modifier le code → dossier sections → Ajouter une section, puis Personnaliser → Ajouter une section.
- Propose-moi d’adapter les couleurs, les textes et les liens à ma marque : demande d’abord mes couleurs (codes hexadécimaux), mon ton et mes liens.
- Garde le bloc {% schema %} et tous ses réglages (identifiants, types, presets) : je dois pouvoir tout régler ensuite dans l’éditeur de thème.
- Rends-moi le fichier complet modifié, prêt à coller, sans faux avis, fausse urgence ni chiffre inventé.

Si tu as le connecteur NAHNAH AI (MCP), récupère directement le code exact avec l’outil obtenir_code_element (id : menu-tiroir-lateral).

Installer dans ma boutique

En un clic, la section est ajoutée à un thème de ta boutique Shopify connectée (un thème non publié par défaut).

Chargement de tes boutiques…

Installer dans Shopify

  1. Dans Shopify : Boutique en ligne → Thèmes → bouton « … » du thème → Modifier le code.
  2. Dossier « sections » → « Ajouter une section » (ou « Nouveau fichier ») → nomme-la « nahnah-menu-tiroir-lateral ».
  3. Efface le contenu proposé, colle le code de l’onglet Liquid (fichier complet), puis Enregistrer.
  4. Ouvre Personnaliser → Ajouter une section → choisis-la, règle les textes et les couleurs, puis Enregistrer.

Installer via le MCP

Depuis Claude, Claude Code ou ChatGPT connecté à NAHNAH AI, demande : « Donne-moi le code de l’élément menu-tiroir-lateral de la bibliothèque NAHNAH AI et les étapes pour l’installer ». L’assistant récupère le code et les étapes (outil obtenir_code_element), gratuitement.

Boutique connectée à NAHNAH AI : l’assistant peut aussi l’installer directement (outil installer_element).

Connecter le MCP

Dans la même catégorie