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

How do i set a different background color based on theme ? #2122

Open
UmbrellaCrow612 opened this issue Jul 31, 2023 · 4 comments
Open

How do i set a different background color based on theme ? #2122

UmbrellaCrow612 opened this issue Jul 31, 2023 · 4 comments

Comments

@UmbrellaCrow612
Copy link

UmbrellaCrow612 commented Jul 31, 2023

i have the basic nextra theme, with light and dark mode, i added tailwind css but in the styles i want to add

@tailwind base;
@tailwind components;
@tailwind utilities;

::selection {
  @apply bg-pink-400 dark:bg-cyan-300
}

but the dark dose not work ?

Or how do i just apply slightly different styles depending on the theme ?

@UmbrellaCrow612
Copy link
Author

@shuding

@UmbrellaCrow612
Copy link
Author

i also tried with plain css

[data-theme='dark'] ::selection {
    background-color: pink;
}

[data-theme='light'] ::selection {
    background-color: pink;
}

@UmbrellaCrow612
Copy link
Author

@B2o5T

@UmbrellaCrow612
Copy link
Author

Found a solution i think

Tailwind config

/** @type {import('tailwindcss').Config} */
module.exports = {
  prefix: "nx-",
  darkMode: ["class", 'html[class~="dark"]'],
  content: [
    "./components/**/*.{ts,tsx}",
    "./pages/**/*.{md,mdx}",
    "./theme.config.tsx",
  ],
};

then _app.mdx

import '../global.css'

export default function App({ Component, pageProps }) {
  return (
    <div className="selection:nx-bg-pink-400 dark:selection:nx-bg-slate-100">
      <Component {...pageProps} />
    </div>
  )
}

seems to work

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

1 participant