Skip to content

Feature Request: Generate multiple independent selectors from a single condition (not nested like mixed conditions) #3296

Closed
@devunt

Description

@devunt

Description

PandaCSS currently supports mixed conditions that create nested selectors, but there's no way to generate multiple independent selectors from a single condition.

Current Behavior - Mixed Conditions

conditions: {
  extend: {
    supportHover: ['@media (hover: hover) and (pointer: fine)', '&:hover'],
  }
}

Generates:

@media (hover: hover) and (pointer: fine) {
  &:hover {
    /* styles */
  }
}

Desired Behavior

// Usage
css({
  _dark: {
    backgroundColor: 'gray.950'
  }
})

Should generate:

.dark & {
  background-color: rgb(10, 10, 10);
}

@media (prefers-color-scheme: dark) {
  &:not(.light *) {
    background-color: rgb(10, 10, 10);
  }
}

Use Case

Dark mode that supports both system preferences and manual toggling without duplicating semantic token values:

// Current: must duplicate values
semanticTokens: {
  colors: {
    'bg.primary': {
      value: { 
        base: '{colors.white}',
        _dark: '{colors.gray.950}',      // for .dark class
        _osDark: '{colors.gray.950}'      // for media query - duplicate!
      }
    }
  }
}

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions