Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixed theme and mode conditions #3145

Open
1 of 3 tasks
cgatian opened this issue Feb 18, 2025 · 0 comments
Open
1 of 3 tasks

Mixed theme and mode conditions #3145

cgatian opened this issue Feb 18, 2025 · 0 comments

Comments

@cgatian
Copy link

cgatian commented Feb 18, 2025

Description

When I create a style that contains conditions for a specific theme and mode, I expect the element to be styled appropriately.

Link to Reproduction

Multi-Theme Tokens
https://play.panda-css.com/tSFQVNcX_t

Multi-Theme
https://play.panda-css.com/UvRRJln-EQ

Steps to reproduce

  1. Use the mulit-theme example where pink and blue are defined as themes with selectors.
  2. Notice the generated Tokens CSS contains the proper selector [data-theme="pink"][data-color-mode="dark"] targeting a single element.
  3. Create a style that targets the blue theme and dark mode conditions.
<div data-theme="primary" data-color-mode="dark">
 <div className={css({
            _blueTheme: {
              color: {
                base: 'red',
                _dark: 'yellow'
              }
            }
        })}
      >
</div>
  1. The output Utility CSS that is generated is:
	[data-color-mode="dark"] [data-theme="blue"] .blueTheme\:dark\:c_yellow {
		color: yellow;
	}
  1. Notice that this selector will not target properly because theme and mode conditions are not targeting a single element:

Produced CSS:
[data-color-mode="dark"] [data-theme="blue"]

Desired CSS:
[data-color-mode="dark"][data-theme="blue"]

JS Framework

No response

Panda CSS Version

0.53.0

Browser

No response

Operating System

  • macOS
  • Windows
  • Linux

Additional Information

I can make additional conditions that properly match based on theme and mode:

  conditions: {
    light: '[data-color-mode=light] &',
    dark: '[data-color-mode=dark] &',
    primaryTheme: '[data-theme=primary] &',
    secondaryTheme: '[data-theme=secondary] &',
    darkPrimary: '[data-theme=primary][data-color-mode=dark] &', // Extra condition
    darkSecondary: '[data-theme=secondary][data-color-mode=dark] &' // Extra condition
  }

However, something feels off about how the conditions work as expected when generating the Token CSS and how the Utilities are generated in code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant