Skip to content

dark: variant styles don't apply inside custom dark themes (e.g. yellow-dark) #469

@pvinis

Description

@pvinis

We have a custom "yellow" theme in our app. To support both light and dark modes for it, we created yellow-light and yellow-dark variants. We apply these via ScopedTheme:

<ScopedTheme theme="yellow-dark">
  <Card /> {/* uses dark: utility classes */}
</ScopedTheme>

The problem is that dark: utility classes (like dark:bg-card) don't apply inside ScopedTheme theme="yellow-dark". They work fine under the plain dark theme, but not under any custom theme that's meant to be a dark variant.

This means we can use dark: without a ScopedTheme, but not with one that has a custom dark theme name.

Cause

In src/core/native/store.ts around line 137:

|| (style.theme !== null && theme !== style.theme)

This does a strict equality check. When the active theme is yellow-dark, styles tagged as dark: are skipped because "dark" !== "yellow-dark".

Expected behavior

dark: styles should apply when the active theme is any dark variant (e.g. yellow-dark, blue-dark).

Suggested fix

|| (style.theme !== null && theme !== style.theme && !(style.theme === 'dark' && theme.endsWith('-dark')))

This could also handle light variants with custom light themes:

|| (style.theme !== null && theme !== style.theme && !(style.theme === 'dark' && theme.endsWith('-dark')) && !(style.theme === 'light' && theme.endsWith('-light')))

Reproduction

  1. Define a custom theme yellow-dark in your CSS with dark mode overrides
  2. Wrap a component in <ScopedTheme theme="yellow-dark">
  3. Any dark: utility classes (e.g. dark:bg-card) inside that tree will not be applied

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions