Skip to content

feat(module): support extra per-mode classes on <html> via ui.colorMode #7014

Description

@naruko-hstk

Description

When using a third-party palette keyed on flavor classes (e.g. Catppuccin .latte / .mocha) alongside Nuxt UI, <html> needs both the mode class and the flavor class:

<html class="light latte">
<html class="dark mocha">

There's no config for this today. Toggling the class in a client plugin works, but it flashes on first paint because it runs after color mode's inline script.

Proposal

Accept it through the existing color mode integration and forward it:

// nuxt.config.ts
export default defineNuxtConfig({
  ui: {
    colorMode: {
      extraClass: { light: ['latte'], dark: ['mocha'] },
    },
  },
})

ui.colorMode is a boolean today, so accepting boolean | ColorModeOptions keeps this additive and v4-able:

type ClassNameInput = string | readonly string[]

interface ColorModeOptions {
  extraClass?: Readonly<Partial<Record<'light' | 'dark', ClassNameInput>>>
}

type UiColorModeOption = boolean | ColorModeOptions

It belongs in nuxt.config rather than app.config, because the no-flash script is generated from module options at build time.

Additional context

Related to the multi-theme direction in #6610 (Epic A6, [data-theme] blocks).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageAwaiting initial review and prioritization

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions