Skip to content

Custom theme variables not working in media queries for custom variants #17841

Answered by RobinMalfait
NoelDeMartin asked this question in Help
Discussion options

You must be logged in to vote

Hey!

Unfortunately in CSS you can't use CSS variables in media queries like that. That's one of the reasons why you have to use theme(…) to inline the value.

If you use theme(--breakpoint-md) we inline it to the value of the --breakpoint-md variable which maps to 48rem. That's what you can see here:

.small-md\:bg-green-300 {
  @media (width >= 48rem) {
    background-color: var(--color-green-300);
  }
}

For your custom variable, you use theme(--breakpoint-custom) which does give you the value for the --breakpoint-custom, but that value is another CSS variable which is not supported, that's why you see:

.small-custom\:bg-green-500 {
  @media (width >= var(--breakpoint-md)) {
    background…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@NoelDeMartin
Comment options

Answer selected by NoelDeMartin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #17840 on May 01, 2025 17:12.