Modules UIColor Mode
Color Mode

Color Mode

Dark and Light mode for Nuxt with auto detection

Installation

npm i -D @nuxtjs/color-mode

Setup

Add the following lines to the modules section of nuxt.config.{ts,js}

modules: ['@nuxtjs/color-mode']

Demo

ColorMode.vue
<template>
  <h1 class="demo-text">
    Color mode: {{ $colorMode.value }}
  </h1>
  <select v-model="$colorMode.preference" class="demo-select">
    <option value="system">
      System
    </option>
    <option value="light">
      Light
    </option>
    <option value="dark">
      Dark
    </option>
    <option value="sepia">
      Sepia
    </option>
  </select>
</template>

<style scoped>
.dark-mode .demo-text, .dark-mode .demo-select {
  background-color: black;
  color: white;
}
.light-mode .demo-text, .dark-mode .demo-select {
  background-color: white;
  color: black;
}
.sepia-mode .demo-text, .sepia-mode .demo-select {
  background-color: #FED;
  color: #300;
}
</style>

Color mode: system