Skip to content

ColorModeButton renders both icons at once instead of toggling them with the active theme #5492

@OptoCode

Description

@OptoCode

Environment

Operating System: Windows_NT

  • Node Version: v22.19.0
  • Nuxt Version: 4.1.3
  • CLI Version: 3.29.3
  • Nitro Version: 2.12.7
  • Package Manager: npm@10.9.3

Is this bug related to Nuxt or Vue?

Nuxt

Package

v4.x

Version

4.2.0

Reproduction

File: src/runtime/components/color-mode/ColorModeButton.vue Blob/commit reference: https://github.com/nuxt/ui/blob/5f30ccf32eea86777fc3e4d595c76f009695e6d9/src/runtime/components/color-mode/ColorModeButton.vue

What’s happening
Observed: both the "light" and "dark" icons are visible at the same time in the ColorModeButton.
Blame/Timeline: two weeks ago the component used an approach that resulted in a single icon (the prior implementation worked), and a later change introduced two UIcon elements using Tailwind classes (hidden dark:inline / inline dark:hidden).
Hypothesis: the current template relies on Tailwind’s dark: variants, which require a .dark ancestor class (or a different dark-mode strategy). If the .dark class isn’t present (or Tailwind is configured with darkMode: 'media'), those variants don’t take effect and both icons remain visible.

How to reproduce
Render the ColorModeButton component in an app using the current nuxt/ui version referenced above.
Toggle between dark and light mode.
Observe that both dark and light icons are shown simultaneously.

Expected behavior
Only the icon corresponding to the current color mode should be visible.

Description

The ColorModeButton.vue component (commit 5f30ccf) is affected. See above for explanation.

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions