Skip to content

CSS variables inside media queries are not respected by UniWind #242

@Atotaro98

Description

@Atotaro98

What happened?

When defining typography tokens using CSS variables with UniWind, variables work correctly as long as they are declared only once.
However, when the same variables are redefined inside @media queries, an unexpected behavior occurs: all text-related utilities resolve to the same computed font-size.
This makes it impossible to implement responsive typography using CSS variables, which is a core requirement for design-system-based setups.

Steps to Reproduce

Works correctly:
`@import 'tailwindcss';
@import 'uniwind';

@layer theme {
:root {
--text-xs: 0.75rem;
--text-sm: 0.875rem;
--text-base: 1rem;
--text-lg: 1.125rem;
--text-xl: 1.25rem;
}
}
`
Text utilities (text-xs, text-base, text-lg, etc.) resolve correctly.

Breaks when adding media queries
`@import 'tailwindcss';
@import 'uniwind';

@layer theme {
:root {
--text-base: 1rem;
--text-lg: 1.125rem;
}
}

@media (min-width: 640px) {
:root {
--text-base: 1.125rem;
--text-lg: 1.375rem;
}
}
`

Snack or Repository Link

https://gist.github.com/Atotaro98/f0cd7356d425723371c87fa66da9fa21

Uniwind version

1.2.2

React Native Version

0.83.0

Platforms

iOS, Android

Expo

No

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions