Advanced

Caveats

Important considerations when using Color Mode

When $colorMode.preference is set to 'system', using $colorMode in your Vue template will lead to a flash. This is due to the fact that we cannot know the user preferences when pre-rendering the page since they are detected on client-side.

Avoiding the Flash

To avoid the flash, you have to guard any rendering path which depends on $colorMode with $colorMode.unknown to render a placeholder or use the <ColorScheme> component.

Example

<template>
  <ColorScheme placeholder="..." tag="span">
    Color mode: <b>{{ $colorMode.preference }}</b>
    <span v-if="$colorMode.preference === 'system'">
      (<i>{{ $colorMode.value }}</i> mode detected)
    </span>
  </ColorScheme>
</template>