Hi guys I have a weird issue with astro + tailwind + svelte , I have the following configuration:
tailwind.config.cjs
/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: 'class',
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
theme: {
extend: {},
},
plugins: [],
}
Layout.astro
....
....
<!DOCTYPE html>
<html lang="en" class="dark">
....
....
Then inside my component.svelte i have the following styles
Component.svelte
<script>
</script>
<div>
Test Component
</div>
<style lang="postcss">
div {
@apply dark:bg-zinc-900 bg-slate-50;
}
</style>
And finally index.astro
---
import Layout from "../layouts/Layout.astro";
import Component from "../components/Component.svelte";
---
<Layout title="Welcome to Astro.">
<main>
<Component />
</main>
</Layout>
<style lang="postcss">
</style>
Now my issue is that dark mode doesn't work even if Layout use dark class inside html element, but it works if index.astro use dark class inside main tag.
Am I doing something wrong?