Skip to content

The dark variant is not correctly applied when setting a custom variant #37

@skyecodes

Description

@skyecodes

I'm using the following custom variant for dark:

@import "tailwindcss";
@import "@catppuccin/tailwindcss/mocha.css";
@custom-variant dark (&:where(.dark, .dark *));

Except when I apply the dark class to my html element, the Mocha colors do not apply, and the Latte colors are still applied as if the class wasn't taken into account. After looking into the generated CSS, it looks like this:

@layer base {
  :root {
    /* Latte colors */
  }
  @variant dark {
    :root {
      /* Mocha colors */
    }
  }
  /* Custom theme classes */
}

The issue is that :root is not a child of my dark custom variant definition, they are the same element, but the selector does not apply.
For example, something like this works:

@layer base {
  :root {
    /* Latte colors */
  }
  @variant dark {
    &:root {
      /* Mocha colors */
    }
  }
  /* Custom theme classes */
}

I'm just getting started on Tailwind so maybe there's a workaround that I don't know of. Any ideas?

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