Browse documentation

Reference / Variants & accessibility

Dark mode

Use dark: to provide an alternate palette. The default mode follows the user’s system color-scheme preference.

Working example

Set darkMode to "class" in the configuration if your app owns the theme switch. In that mode a dark class on the component or an ancestor activates the variants.

HTML
<article class="rounded border border-neutral-300 bg-white p-4 text-black dark:border-neutral-600 dark:bg-neutral-900 dark:text-white">
  <h3 class="font-bold">Night proof</h3>
  <p>Check both the paper tone and the ink contrast.</p>
</article>

Class reference

ClassCSS declarations
dark:bg-neutral-900background-color: oklch(0.32 0 0);
dark:text-whitecolor: #fff;
dark:border-neutral-600border-color: oklch(0.56 0 0);
dark:hover:bg-neutral-800background-color: oklch(0.4 0 0);
View full generated CSS
Compiled CSS
@media (prefers-color-scheme: dark) {
  .dark\:border-neutral-600 {
    border-color: oklch(0.56 0 0);
  }
  .dark\:text-white {
    color: #fff;
  }
  .dark\:bg-neutral-900 {
    background-color: oklch(0.32 0 0);
  }
  @media (hover: hover) {
    .dark\:hover\:bg-neutral-800:hover {
      background-color: oklch(0.4 0 0);
    }
  }
}