Color Mode

Nuxt UI integrates with VueUse to allow for easy switching between light and dark themes.

Usage

Nuxt UI automatically registers the useDark composable as a Vue plugin, so there's no additional setup required. You can simply use it to switch between light and dark modes:

ColorModeButton.vue
<script setup>
import { useColorMode } from '@vueuse/core'

const mode = useColorMode()
</script>

<template>
  <UButton
    :icon="mode === 'dark' ? 'i-lucide-moon' : 'i-lucide-sun'"
    color="neutral"
    variant="ghost"
    @click="mode = mode === 'dark' ? 'light' : 'dark'"
  />
</template>

You can disable this plugin with the colorMode option in your vite.config.ts:

vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'

export default defineConfig({
  plugins: [
    vue(),
    ui({
      colorMode: false
    })
  ]
})