Préférences d'affichage (header)

Le bouton engrenage du header : mode sombre, polices adaptées et couleurs du site, au choix de chaque visiteur.

Mode sombre et polices

Trois cases à cocher pour adapter l'affichage : le mode sombre et deux polices pensées pour la lecture.

Comment ça marche ?

Le bouton .ulk-c-header-utilities__button ouvre un menu déroulant Bootstrap avec trois cases à cocher. components.js les repère par leur identifiant et applique le choix à toute la page :

  • #darkmodeCheckbox : mode sombre
  • #dyslexiaFontCheckbox : police OpenDyslexic
  • #lucioleFontCheckbox : police Luciole

Les identifiants sont imposés : avec un autre id, la case ne fait plus rien. Les deux polices s'excluent, en cocher une décoche l'autre.

Le choix est mémorisé dans le navigateur et conservé d'une page à l'autre. Sans choix enregistré, le mode sombre suit le réglage du système.

Le détail des classes posées sur <html> et des clés enregistrées est sur la page JavaScript.

Voir la page JavaScript

Dans l'aperçu ci-dessous, cliquez sur l'engrenage pour activer le mode sombre ou changer de police.

<div class="demo-scene">
    <!-- Bouton seul : hors de .ulk-c-header-utilities (masqu&eacute;e sous 1200px), il reste visible &agrave; toutes les largeurs. -->
    <div class="ulk-s-frame ulk-s-frame-pt-xs ulk-s-frame-pb-xs ulk-th-bg-neutral1">
      <div class="ulk-s-container">
        <div class="ulk-c-header-utilities__item ulk-c-bottom-sheet">
          <button type="button" data-bs-auto-close="outside" data-bs-toggle="dropdown" aria-expanded="false" class="ulk-c-header-utilities__button">
            <i class="ulkicon ulkicon-control--gear-outline" aria-hidden="true"></i>
            <span class="u-sr-only">Paramètrer l'affichage du site</span>
          </button>
          <div class="dropdown-menu ulk-c-dropdown-menu">
            <div class="ulk-c-dropdown-menu__item ulk-c-dropdown-menu__item--title ulk-c-dropdown-menu__item--help-link">
              <div class="ulk-c-dropdown-menu__item-content">
                <p class="ulk-c-dropdown-menu__title">Accessibilité</p>
                <a href="#" class="ulk-c-dropdown-menu__help-link">
                  <i class="ulkicon ulkicon-status--information2 ulk-c-dropdown-menu__help-link-icon" aria-hidden="true"> </i>
                  <span>Mode d'emploi</span><span class="u-sr-only"> pour l'accessibilité</span>
                </a>
              </div>
            </div>
            <ul class="ulk-c-dropdown-menu__items-container">
              <li class="ulk-c-divider-horizontal" aria-hidden="true">
                <div class="ulk-c-divider-horizontal__divider"></div>
              </li>
              <li class="ulk-c-dropdown-menu__item ulk-c-dropdown-menu__item--checkbox">
                <div class="ulk-c-dropdown-menu__item-content">
                  <div class="ulk-c-checkbox">
                    <input id="darkmodeCheckbox" name="darkmodeCheckbox" type="checkbox" class="ulk-c-checkbox__input">
                    <label for="darkmodeCheckbox" class="ulk-c-checkbox__label">Mode
                      sombre</label>
                  </div>
                </div>
              </li>
              <li class="ulk-c-dropdown-menu__item ulk-c-dropdown-menu__item--checkbox">
                <div class="ulk-c-dropdown-menu__item-content">
                  <div class="ulk-c-checkbox">
                    <input id="dyslexiaFontCheckbox" name="dyslexiaFontCheckbox" type="checkbox" class="ulk-c-checkbox__input">
                    <label for="dyslexiaFontCheckbox" class="ulk-c-checkbox__label">Police
                      dyslexique</label>
                  </div>
                </div>
              </li>
              <li class="ulk-c-dropdown-menu__item ulk-c-dropdown-menu__item--checkbox">
                <div class="ulk-c-dropdown-menu__item-content">
                  <div class="ulk-c-checkbox">
                    <input id="lucioleFontCheckbox" name="lucioleFontCheckbox" type="checkbox" class="ulk-c-checkbox__input">
                    <label for="lucioleFontCheckbox" class="ulk-c-checkbox__label">Police
                      "Luciole" (pour malvoyants)</label>
                  </div>
                </div>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>

    <!-- Texte t&eacute;moin : montre le changement de police et de mode -->
    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-bg">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Texte témoin</h2>
          <p>Ouvrez l'engrenage et cochez une option : la police et les couleurs de ce texte changent
            aussitôt.</p>
          <p class="ulk-t-paragraph-emphasis">Le choix est conservé d'une page à l'autre.</p>
        </div>
      </div>
    </div>
  </div>

Les polices

Chaque police proposée répond à un besoin d'accessibilité :

Police Pour qui
Source Sans 3 police par défaut du design system
OpenDyslexic lecteurs dyslexiques : lettres alourdies vers le bas, formes plus faciles à distinguer (b/d, p/q)
Luciole personnes malvoyantes : conçue pour la basse vision par le Centre Technique Régional pour la Déficience Visuelle

Chargement à distance

Les polices sont déclarées dans ulk-fonts.css, servi par ulk.univ-lille.fr avec ses fichiers : rien à héberger côté site.

<link href="https://ulk.univ-lille.fr/dist/ulk-fonts.css" rel="stylesheet" />

Le navigateur ne télécharge OpenDyslexic ou Luciole que si le visiteur les active.

Le changement passe par la variable --local-font-sans. Dans le CSS d'un site, ne jamais fixer une font-family en dur : le texte concerné ne suivrait plus le choix du visiteur.

Le choix des couleurs

Le visiteur peut remplacer les couleurs du site par l'un des 13 thèmes ULK. Le thème choisi remplace les couleurs primary1, primary2, l'accent et la couleur secondaire.

Le menu est un groupe de boutons radio .ulk-c-theme-picker, placé dans le menu engrenage. Au clavier, les flèches passent d'un thème à l'autre. Sur mobile, les noms des thèmes sont masqués visuellement (mais lus par les lecteurs d'écran) et les pastilles s'agrandissent pour le toucher.

<fieldset class="ulk-c-theme-picker" data-default-theme="12">
    <legend class="ulk-c-theme-picker__legend ulk-c-dropdown-menu__item ulk-c-dropdown-menu__item--title">
        <span class="ulk-c-dropdown-menu__item-content">
            <span class="ulk-c-dropdown-menu__title">Couleurs</span>
        </span>
    </legend>
    <div class="ulk-c-theme-picker__list">
        <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme1">
            <input type="radio" name="ulkColorTheme" value="1" class="ulk-c-theme-picker__input">
            <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
            <span class="ulk-c-theme-picker__name">Neutre</span>
        </label>
        <!-- … une option par thème, de 1 à 13 -->
    </div>
</fieldset>
Élément Rôle
data-default-theme Numéro du thème du site, celui de son custom.css (ex. 11 pour Colvert sur le CAS). Ce thème est coché tant que le visiteur n'a rien choisi
value Numéro du thème, de 1 à 13
.ulk-c-theme-picker__option--themeN Colore les deux pastilles avec primary1 et primary2 du thème N

Ce qui est mémorisé. Si le visiteur choisit un autre thème que celui du site, il le retrouve au rechargement et sur les autres pages. S'il revient au thème du site, son choix est oublié : le site affiche de nouveau les couleurs de son custom.css. Si le site change un jour de thème, ce visiteur verra donc le nouveau.

Noms des thèmes : 1 Neutre, 2 Industrie, 3 Pink Lady, 4 Brique du Nord, 5 Orangette, 6 Hypérion, 7 Océan, 8 Menthe, 9 Dune, 10 Commodore, 11 Colvert, 12 Vulcain, 13 Orange Sanguine.

Dans l'aperçu ci-dessous, cliquez sur l'engrenage et choisissez un thème : les blocs changent de couleur.

<div class="demo-scene">
    <!-- Bouton de pr&eacute;f&eacute;rences seul : hors de .ulk-c-header-utilities (masqu&eacute;e sous 1200px), il reste visible &agrave; toutes les largeurs. -->
    <div class="ulk-s-frame ulk-s-frame-pt-xs ulk-s-frame-pb-xs ulk-th-bg-neutral1">
      <div class="ulk-s-container">
        <div class="ulk-c-header-utilities__item ulk-c-bottom-sheet">
          <button type="button" data-bs-auto-close="outside" data-bs-toggle="dropdown" aria-expanded="false" class="ulk-c-header-utilities__button">
            <i class="ulkicon ulkicon-control--gear-outline" aria-hidden="true"></i>
            <span class="u-sr-only">Paramètrer l'affichage du site</span>
          </button>
          <div class="dropdown-menu ulk-c-dropdown-menu">
            <!-- data-default-theme = th&egrave;me du site (celui de son :root). Noms des th&egrave;mes : https://ulk.univ-lille.fr/docs/couleurs -->
            <fieldset class="ulk-c-theme-picker" data-default-theme="12">
              <legend class="ulk-c-theme-picker__legend ulk-c-dropdown-menu__item ulk-c-dropdown-menu__item--title">
                <span class="ulk-c-dropdown-menu__item-content">
                  <span class="ulk-c-dropdown-menu__title">Couleurs</span>
                </span>
              </legend>
              <div class="ulk-c-theme-picker__list">
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme1">
                  <input type="radio" name="ulkColorTheme" value="1" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Neutre</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme2">
                  <input type="radio" name="ulkColorTheme" value="2" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Industrie</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme3">
                  <input type="radio" name="ulkColorTheme" value="3" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Pink Lady</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme4">
                  <input type="radio" name="ulkColorTheme" value="4" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Brique du Nord</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme5">
                  <input type="radio" name="ulkColorTheme" value="5" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Orangette</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme6">
                  <input type="radio" name="ulkColorTheme" value="6" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Hypérion</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme7">
                  <input type="radio" name="ulkColorTheme" value="7" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Océan</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme8">
                  <input type="radio" name="ulkColorTheme" value="8" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Menthe</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme9">
                  <input type="radio" name="ulkColorTheme" value="9" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Dune</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme10">
                  <input type="radio" name="ulkColorTheme" value="10" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Commodore</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme11">
                  <input type="radio" name="ulkColorTheme" value="11" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Colvert</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme12">
                  <input type="radio" name="ulkColorTheme" value="12" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Vulcain</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme13">
                  <input type="radio" name="ulkColorTheme" value="13" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Orange Sanguine</span>
                </label>
              </div>
            </fieldset>
          </div>
        </div>
      </div>
    </div>

    <!-- Blocs t&eacute;moins : ce qui suit le th&egrave;me choisi -->
    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-bg">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Fond de page</h2>
          <p>Le fond ne change pas. <a href="#">Les liens</a> et l'emphase prennent la couleur d'accent du thème choisi.</p>
          <p class="ulk-t-paragraph-emphasis">Texte d'emphase en couleur d'accent.</p>
          <p><a href="#" class="ulk-c-button">Un bouton primary1</a></p>
        </div>
      </div>
    </div>

    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-block-primary1">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Bloc primary1</h2>
          <p>Prend la couleur primary1 du thème choisi.</p>
          <p><a href="#" class="ulk-c-button">Un bouton</a></p>
        </div>
      </div>
    </div>

    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-block-primary2">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Bloc primary2</h2>
          <p>Prend la couleur primary2 du thème choisi.</p>
          <p><a href="#" class="ulk-c-button">Un bouton</a></p>
        </div>
      </div>
    </div>

    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-block-secondary1">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Bloc secondary1</h2>
          <p>Prend aussi les couleurs du thème choisi (ou le thème Neutre si &lt;html&gt; porte data-ulk-secondary="neutral").</p>
          <p><a href="#" class="ulk-c-button">Un bouton</a></p>
        </div>
      </div>
    </div>

    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-block-secondary2">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Bloc secondary2</h2>
          <p>Suit le thème choisi comme secondary1.</p>
          <p><a href="#" class="ulk-c-button">Un bouton</a></p>
        </div>
      </div>
    </div>
  </div>

Ce qui se passe

components.js pose l'attribut data-ulk-theme="N" sur <html> et mémorise le choix dans localStorage (clé ulk.themeIndex). Le CSS du design system redéfinit alors les variables --local-bg-primary1, --local-bg-primary2, --local-fg-accent1 (et leurs variantes -rgb et -darkmode) ainsi que --local-bg-secondary1 et --local-bg-secondary2. Tout ce qui s'appuie sur ces variables suit, y compris en mode sombre.

La couleur secondaire

Dans ses fichiers (custom.css), un site peut associer deux thèmes différents : l'un pour primary, l'autre pour secondary. Le choix du visiteur, lui, porte sur un seul thème : un secondaire pensé pour le thème du site n'irait plus avec celui du visiteur. Dès que le visiteur choisit un thème, la couleur secondaire suit donc l'une de ces deux règles, au choix du développeur :

Sur <html> Couleur secondaire après un choix du visiteur
rien (par défaut) les couleurs du thème choisi
data-ulk-secondary="neutral" le thème Neutre (1)
<html lang="fr" data-ulk-secondary="neutral">

Tant que le visiteur n'a rien choisi, ou s'il revient au thème du site, le site affiche son propre custom.css, secondaire compris. Pour que la couleur secondaire ne change pas de logique à ce moment-là, un site qui propose ce menu suit la même règle dans son custom.css : secondaire calé sur son thème principal, ou sur le thème Neutre avec data-ulk-secondary="neutral". Les sites à deux thèmes (TYPO3) n'ont pas vocation à proposer ce menu.

L'aperçu ci-dessous reprend la démo précédente avec data-ulk-secondary="neutral" : quel que soit le thème choisi, les blocs secondary restent en Neutre.

<div class="demo-scene">
    <!-- Bouton de pr&eacute;f&eacute;rences seul : hors de .ulk-c-header-utilities (masqu&eacute;e sous 1200px), il reste visible &agrave; toutes les largeurs. -->
    <div class="ulk-s-frame ulk-s-frame-pt-xs ulk-s-frame-pb-xs ulk-th-bg-neutral1">
      <div class="ulk-s-container">
        <div class="ulk-c-header-utilities__item ulk-c-bottom-sheet">
          <button type="button" data-bs-auto-close="outside" data-bs-toggle="dropdown" aria-expanded="false" class="ulk-c-header-utilities__button">
            <i class="ulkicon ulkicon-control--gear-outline" aria-hidden="true"></i>
            <span class="u-sr-only">Paramètrer l'affichage du site</span>
          </button>
          <div class="dropdown-menu ulk-c-dropdown-menu">
            <!-- data-default-theme = th&egrave;me du site (celui de son :root). Noms des th&egrave;mes : https://ulk.univ-lille.fr/docs/couleurs -->
            <fieldset class="ulk-c-theme-picker" data-default-theme="12">
              <legend class="ulk-c-theme-picker__legend ulk-c-dropdown-menu__item ulk-c-dropdown-menu__item--title">
                <span class="ulk-c-dropdown-menu__item-content">
                  <span class="ulk-c-dropdown-menu__title">Couleurs</span>
                </span>
              </legend>
              <div class="ulk-c-theme-picker__list">
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme1">
                  <input type="radio" name="ulkColorTheme" value="1" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Neutre</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme2">
                  <input type="radio" name="ulkColorTheme" value="2" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Industrie</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme3">
                  <input type="radio" name="ulkColorTheme" value="3" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Pink Lady</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme4">
                  <input type="radio" name="ulkColorTheme" value="4" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Brique du Nord</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme5">
                  <input type="radio" name="ulkColorTheme" value="5" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Orangette</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme6">
                  <input type="radio" name="ulkColorTheme" value="6" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Hypérion</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme7">
                  <input type="radio" name="ulkColorTheme" value="7" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Océan</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme8">
                  <input type="radio" name="ulkColorTheme" value="8" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Menthe</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme9">
                  <input type="radio" name="ulkColorTheme" value="9" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Dune</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme10">
                  <input type="radio" name="ulkColorTheme" value="10" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Commodore</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme11">
                  <input type="radio" name="ulkColorTheme" value="11" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Colvert</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme12">
                  <input type="radio" name="ulkColorTheme" value="12" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Vulcain</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme13">
                  <input type="radio" name="ulkColorTheme" value="13" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Orange Sanguine</span>
                </label>
              </div>
            </fieldset>
          </div>
        </div>
      </div>
    </div>

    <!-- Blocs t&eacute;moins : ce qui suit le th&egrave;me choisi -->
    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-bg">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Fond de page</h2>
          <p>Le fond ne change pas. <a href="#">Les liens</a> et l'emphase prennent la couleur d'accent du thème choisi.</p>
          <p class="ulk-t-paragraph-emphasis">Texte d'emphase en couleur d'accent.</p>
          <p><a href="#" class="ulk-c-button">Un bouton primary1</a></p>
        </div>
      </div>
    </div>

    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-block-primary1">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Bloc primary1</h2>
          <p>Prend la couleur primary1 du thème choisi.</p>
          <p><a href="#" class="ulk-c-button">Un bouton</a></p>
        </div>
      </div>
    </div>

    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-block-primary2">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Bloc primary2</h2>
          <p>Prend la couleur primary2 du thème choisi.</p>
          <p><a href="#" class="ulk-c-button">Un bouton</a></p>
        </div>
      </div>
    </div>

    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-block-secondary1">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Bloc secondary1</h2>
          <p>Prend aussi les couleurs du thème choisi (ou le thème Neutre si &lt;html&gt; porte data-ulk-secondary="neutral").</p>
          <p><a href="#" class="ulk-c-button">Un bouton</a></p>
        </div>
      </div>
    </div>

    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-block-secondary2">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Bloc secondary2</h2>
          <p>Suit le thème choisi comme secondary1.</p>
          <p><a href="#" class="ulk-c-button">Un bouton</a></p>
        </div>
      </div>
    </div>
  </div>

Au chargement de la page

Pour éviter que la page s'affiche un instant avec les couleurs par défaut, ajoutez ce script dans le <head>, avant les feuilles de style :

<script>
    try {
        var ulkTheme = localStorage.getItem('ulk.themeIndex');
        if (/^([1-9]|1[0-3])$/.test(ulkTheme || '')) document.documentElement.setAttribute('data-ulk-theme', ulkTheme);
    } catch (e) { }
</script>

Dans le CSS d'un site, ne fixez jamais une couleur de thème en dur : passez par les variables --local-*, sinon l'élément ne suivra pas le choix du visiteur.

Tout en même temps

Les deux se combinent dans le même menu : les cases d'accessibilité d'abord, puis, sous un séparateur, le choix des couleurs. Chaque préférence est mémorisée séparément.

En mode sombre, le thème choisi s'applique aussi : l'accent passe à sa variante sombre, les blocs primary et secondary gardent leurs couleurs.

Dans l'aperçu ci-dessous, activez le mode sombre puis changez de thème.

<div class="demo-scene">
    <!-- Bouton de pr&eacute;f&eacute;rences seul : hors de .ulk-c-header-utilities (masqu&eacute;e sous 1200px), il reste visible &agrave; toutes les largeurs. -->
    <div class="ulk-s-frame ulk-s-frame-pt-xs ulk-s-frame-pb-xs ulk-th-bg-neutral1">
      <div class="ulk-s-container">
        <div class="ulk-c-header-utilities__item ulk-c-bottom-sheet">
          <button type="button" data-bs-auto-close="outside" data-bs-toggle="dropdown" aria-expanded="false" class="ulk-c-header-utilities__button">
            <i class="ulkicon ulkicon-control--gear-outline" aria-hidden="true"></i>
            <span class="u-sr-only">Paramètrer l'affichage du site</span>
          </button>
          <div class="dropdown-menu ulk-c-dropdown-menu">
            <div class="ulk-c-dropdown-menu__item ulk-c-dropdown-menu__item--title ulk-c-dropdown-menu__item--help-link">
              <div class="ulk-c-dropdown-menu__item-content">
                <p class="ulk-c-dropdown-menu__title">Accessibilité</p>
                <a href="#" class="ulk-c-dropdown-menu__help-link">
                  <i class="ulkicon ulkicon-status--information2 ulk-c-dropdown-menu__help-link-icon" aria-hidden="true"> </i>
                  <span>Mode d'emploi</span><span class="u-sr-only"> pour l'accessibilité</span>
                </a>
              </div>
            </div>
            <ul class="ulk-c-dropdown-menu__items-container">
              <li class="ulk-c-divider-horizontal" aria-hidden="true">
                <div class="ulk-c-divider-horizontal__divider"></div>
              </li>
              <li class="ulk-c-dropdown-menu__item ulk-c-dropdown-menu__item--checkbox">
                <div class="ulk-c-dropdown-menu__item-content">
                  <div class="ulk-c-checkbox">
                    <input id="darkmodeCheckbox" name="darkmodeCheckbox" type="checkbox" class="ulk-c-checkbox__input">
                    <label for="darkmodeCheckbox" class="ulk-c-checkbox__label">Mode
                      sombre</label>
                  </div>
                </div>
              </li>
              <li class="ulk-c-dropdown-menu__item ulk-c-dropdown-menu__item--checkbox">
                <div class="ulk-c-dropdown-menu__item-content">
                  <div class="ulk-c-checkbox">
                    <input id="dyslexiaFontCheckbox" name="dyslexiaFontCheckbox" type="checkbox" class="ulk-c-checkbox__input">
                    <label for="dyslexiaFontCheckbox" class="ulk-c-checkbox__label">Police
                      dyslexique</label>
                  </div>
                </div>
              </li>
              <li class="ulk-c-dropdown-menu__item ulk-c-dropdown-menu__item--checkbox">
                <div class="ulk-c-dropdown-menu__item-content">
                  <div class="ulk-c-checkbox">
                    <input id="lucioleFontCheckbox" name="lucioleFontCheckbox" type="checkbox" class="ulk-c-checkbox__input">
                    <label for="lucioleFontCheckbox" class="ulk-c-checkbox__label">Police
                      "Luciole" (pour malvoyants)</label>
                  </div>
                </div>
              </li>
            </ul>
            <!-- Choix des couleurs : data-default-theme = th&egrave;me du site (celui de son :root). Noms des th&egrave;mes : https://ulk.univ-lille.fr/docs/couleurs -->
            <div class="ulk-c-divider-horizontal" aria-hidden="true">
              <div class="ulk-c-divider-horizontal__divider"></div>
            </div>
            <fieldset class="ulk-c-theme-picker" data-default-theme="12">
              <legend class="ulk-c-theme-picker__legend ulk-c-dropdown-menu__item ulk-c-dropdown-menu__item--title">
                <span class="ulk-c-dropdown-menu__item-content">
                  <span class="ulk-c-dropdown-menu__title">Couleurs</span>
                </span>
              </legend>
              <div class="ulk-c-theme-picker__list">
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme1">
                  <input type="radio" name="ulkColorTheme" value="1" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Neutre</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme2">
                  <input type="radio" name="ulkColorTheme" value="2" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Industrie</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme3">
                  <input type="radio" name="ulkColorTheme" value="3" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Pink Lady</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme4">
                  <input type="radio" name="ulkColorTheme" value="4" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Brique du Nord</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme5">
                  <input type="radio" name="ulkColorTheme" value="5" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Orangette</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme6">
                  <input type="radio" name="ulkColorTheme" value="6" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Hypérion</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme7">
                  <input type="radio" name="ulkColorTheme" value="7" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Océan</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme8">
                  <input type="radio" name="ulkColorTheme" value="8" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Menthe</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme9">
                  <input type="radio" name="ulkColorTheme" value="9" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Dune</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme10">
                  <input type="radio" name="ulkColorTheme" value="10" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Commodore</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme11">
                  <input type="radio" name="ulkColorTheme" value="11" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Colvert</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme12">
                  <input type="radio" name="ulkColorTheme" value="12" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Vulcain</span>
                </label>
                <label class="ulk-c-theme-picker__option ulk-c-theme-picker__option--theme13">
                  <input type="radio" name="ulkColorTheme" value="13" class="ulk-c-theme-picker__input">
                  <span class="ulk-c-theme-picker__swatches" aria-hidden="true"><span class="ulk-c-theme-picker__swatch"></span><span class="ulk-c-theme-picker__swatch"></span></span>
                  <span class="ulk-c-theme-picker__name">Orange Sanguine</span>
                </label>
              </div>
            </fieldset>
          </div>
        </div>
      </div>
    </div>

    <!-- Fond de page : texte et emphase s'inversent -->
    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-bg">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Fond de page</h2>
          <p>Le fond passe au foncé et le texte au clair, sans aucun CSS en plus.</p>
          <p class="ulk-t-paragraph-emphasis">L'emphase prend la couleur d'accent du thème choisi, en variante sombre en mode sombre.</p>
        </div>
      </div>
    </div>

    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-block-primary1">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Bloc primary1</h2>
          <p>Ne change pas en mode sombre. Prend la couleur primary1 du thème choisi.</p>
          <p><a href="#" class="ulk-c-button">Un bouton</a></p>
        </div>
      </div>
    </div>

    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-block-primary2">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Bloc primary2</h2>
          <p>Ne change pas en mode sombre. Prend la couleur primary2 du thème choisi.</p>
          <p><a href="#" class="ulk-c-button">Un bouton</a></p>
        </div>
      </div>
    </div>

    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-block-secondary1">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Bloc secondary1</h2>
          <p>Ne change pas en mode sombre. Quand le visiteur choisit un thème, prend aussi ses couleurs
            (ou le thème Neutre si &lt;html&gt; porte data-ulk-secondary="neutral").</p>
          <p><a href="#" class="ulk-c-button">Un bouton</a></p>
        </div>
      </div>
    </div>

    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-block-secondary2">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Bloc secondary2</h2>
          <p>Ne change pas en mode sombre. Suit le thème choisi comme secondary1.</p>
          <p><a href="#" class="ulk-c-button">Un bouton</a></p>
        </div>
      </div>
    </div>

    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-block-revert">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Bloc revert</h2>
          <p>Toujours à l'inverse du fond de page : sombre en mode clair, clair en mode sombre.</p>
        </div>
      </div>
    </div>

    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-bg-neutral1">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Fond neutral1</h2>
          <p>Suit le mode, comme le fond de page.</p>
        </div>
      </div>
    </div>

    <div class="ulk-s-frame ulk-s-frame-pt-sm ulk-s-frame-pb-sm ulk-th-bg-neutral2">
      <div class="ulk-s-container">
        <div class="ulk-s-text-container">
          <h2 class="ulk-t-title-sm-bold">Fond neutral2</h2>
          <p>Suit le mode, comme le fond de page.</p>
        </div>
      </div>
    </div>
  </div>

Prochainement

  • Une instruction d'utilisation. Le RGAA 5 impose qu'un élément de ce type indique visiblement à quoi il sert et comment il fonctionne. Une instruction sera ajoutée au menu.