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

Issue with UnoCSS theme function returning non-color value #3617

Open
4 tasks done
FE-runner opened this issue Mar 13, 2024 · 1 comment
Open
4 tasks done

Issue with UnoCSS theme function returning non-color value #3617

FE-runner opened this issue Mar 13, 2024 · 1 comment

Comments

@FE-runner
Copy link

UnoCSS version

0.58.5

Describe the bug

When using UnoCSS with Scss, there is an inconsistency in how colors are handled when retrieved using the theme function. While variables defined directly as colors ($v1: blue;) behave as expected, those retrieved through the theme('colors.blue.500') function are not recognized as colors in certain Sass functions such as mix, transparentize, and rgba. This inconsistency leads to errors when attempting to manipulate colors retrieved via the theme function.

Reproduction

  $v1: blue;
  $v2: theme('colors.blue.500');
  .a1 {
    background: $v1; //ok
    background: $v2; //ok
    background: mix($v1, #fff, 0.5); //ok
    background: transparentize($v1, 0.5); //ok
    background: rgba($v1, 0.5); //ok
    background: mix($v2, #fff, 0.5); //no $color1: theme("colors.blue.500") is not a color.
    background: transparentize($v2, 0.5); //no $color1: theme("colors.blue.500") is not a color.
    background: rgba($v2, 0.5); //no $color1: theme("colors.blue.500") is not a color.
  }

System Info

No response

Validations

@lzl0304
Copy link
Contributor

lzl0304 commented Mar 18, 2024

Sass, Less, Stylus, and other preprocessors run separately before UnoCSS. This means that you cannot input the output of the theme() function into Sass color functions, as theme() is only truly calculated after your Sass has been compiled to CSS and input into UnoCSS.

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

2 participants