question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorect css order for custom color + dark mode + bg-opacity

See original GitHub issue

Minimal demo: https://github.com/xorik/vite-dark-bg-opacity

Hi. Custom color + bg opacity works fine for normal mode, but CSS order seems incorrect for dark mode.

Expected (added !important to all opacity classes): Screen Shot 2021-05-24 at 21 28 57

Actual: Screen Shot 2021-05-24 at 21 28 26

Devtool screenshot: Screen Shot 2021-05-24 at 21 30 07

HTML:

    <div class="flex h-20 my-10 justify-between">
      <div class="bg-primary flex-1"></div>
      <div class="bg-primary flex-1 bg-opacity-70"></div>
      <div class="bg-primary flex-1 bg-opacity-50"></div>
      <div class="bg-primary flex-1 bg-opacity-20"></div>
    </div>

    <div class="dark bg-dark-400 py-10">
      <div class="flex h-20 my-10 justify-between">
        <div class="dark:bg-primary flex-1"></div>
        <div class="dark:bg-primary flex-1 bg-opacity-70"></div>
        <div class="dark:bg-primary flex-1 bg-opacity-50"></div>
        <div class="dark:bg-primary flex-1 bg-opacity-20"></div>
      </div>
    </div>

Config:

{
  purge: [],
  darkMode: 'class', // or 'media' or 'class'
  theme: {
    extend: {
      backgroundColor: {
        primary: ({ opacityValue }) => {
          if (opacityValue !== undefined) {
            return `rgba(30, 58, 138, ${opacityValue})`;
          }
          return `rgb(30, 58, 138)`;
        }
      }
    },
  },
  variants: {},
  plugins: [],
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
voorjaarcommented, Jun 3, 2021

today or tomorrow.

1reaction
voorjaarcommented, May 25, 2021

actually we have a new feature from next version can solve this better.

   <div class="bg-primary/70 ...">
   <div class="dark:bg-primary/50 ...">

https://github.com/windicss/windicss/blob/31c270185811d1864072ee23944b92bc8e753ece/test/processor/__snapshots__/utilities.test.ts.yml#L130-L133

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dark Mode in CSS
“Dark mode” is defined as a color scheme that uses light-colored text and other UI elements on a dark-colored background. Dark mode, dark...
Read more >
dark variant not respecting bg-opacity #2966 - GitHub
Describe the problem: I have darkMode: 'class' in my config. ... is only applied in light mode, but in dark mode bg-opacity is...
Read more >
How do I apply opacity to a CSS color variable? - Stack Overflow
I solved this issue now, by applying the background-color and the opacity to a pseudo :after or ... If you use dark and...
Read more >
prefers-color-scheme - CSS: Cascading Style Sheets | MDN
Indicates that user has notified that they prefer an interface that has a light theme, or has not expressed an active preference. dark....
Read more >
How to Set Opacity of Images, Text & More in CSS
Below, I'll set a paragraph to be slightly transparent against a dark solid background color. HTML; CSS. Result; Skip Results Iframe.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found