 
  
  :root {
  --primary-color: #f9f9f9;
  --text-color: #424242;
}
:root.dark-mode {
  --primary-color: #161625;
  --text-color: #e1e1ff;
}
body {
  background: var(--primary-color);
  color: var(--text-color);
}css или js файлов, которое вы подключаете на своих страницах посредством тэгов <link> и <src>.  
  
  var clickId1 = document.getElementById('clickId1') // кнопка
var contentId1 = document.getElementById('contentId1') // контент
const myClass = 'contentClass2'
switch(localStorage.getItem('theme')) {
  case myClass:
    contentId1.classList.toggle(myClass)
}
clickId1.addEventListener('click', () => {
  contentId1.classList.toggle(myClass)
  if (contentId1.classList.contains(myClass)) {
    localStorage.setItem('theme', myClass);
  } else {
    localStorage.removeItem('theme', myClass);
  }
})загрузка страницы
  текущий цвет = есть что в LS ? что-то из LS  :  цвет-по-умолчанию
нажали на кнопку
  поменяли цвет
  сохранили в LSзагрузка страницы
  переменная_Состояние = значение-по-умолчанию (true или false)
  есть что в LS ?  переменная_Состояние значение из LS
  сделать цвет по Состоянию
нажатие кнопки
  обновить переменную_Состояния
  сохранить в LS
  сделать цвет по Состоянию(function () {
  const storageKey = 'theme';
  const state =  {}
  const stored = localStorage.getItem(storageKey);
  state.theme = stored ? JSON.parse(stored) : false; // default
  const el = document.querySelector('#pink');
  const render = () => el.classList[state.theme ? 'add' : 'remove']('blueTheme');
  render();
  const toggleTheme = () => {
    state.theme = ! state.theme;
    localStorage.setItem(storageKey, JSON.stringify(state.theme));
    render();
  }
  el.addEventListener('click', toggleTheme);
}())if (localStorage.getItem('theme') !== null) {
    localStorage.getItem('theme') // эта строка ничего не делает
}(function () {
  const blue = document.querySelector('#pink')
  switch (localStorage.getItem('theme')) {
      case 'blueTheme':
          blue.classList.add('blueTheme')
  }
  blue.addEventListener('click', () => {
    if (blue.classList.contains('blueTheme')) {
        blue.classList.add('blueTheme')
        localStorage.setItem('theme', 'blueTheme')
    } else {
        blue.classList.remove('blueTheme')
        localStorage.removeItem('theme')
    }
  })
}())