nativewind icon indicating copy to clipboard operation
nativewind copied to clipboard

Dark mode not working in v4

Open tarifalhasan opened this issue 1 year ago • 1 comments

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Expo Snack If applicable, add a link to an Expo snack demonstrating the issue. There are multiple example snacks available at nativewind.dev.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

tarifalhasan avatar May 14 '24 06:05 tarifalhasan

@tarifalhasan, please review the settings on my project here : https://github.com/launchtrack/expo-starter to ensure nothing has been overlooked.

younes200 avatar May 14 '24 11:05 younes200

I was having problem with the dark mode functionality in my app as well and I found out that I by accident changed the .dark selector in global.css from .dark:root to .dark. Hopefully this can help someone else!

desiboli avatar May 20 '24 09:05 desiboli

Here is a dark mode example with custom colors:

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

@layer base {
  :root {
    --background: 40 30% 96%;
    --foreground: 40 5% 12%;

  }
  .dark:root {
    --background: 40 5% 12%;
    --foreground: 40 30% 96%;
  }

  .default-bg {
    @apply background dark:background;
  }
}
module.exports = {
  darkMode: 'class',
  content: ['./src/**/*.{ts,tsx,svg}'],
  presets: [require('nativewind/preset')],
  theme: {
    extend: {
      colors: {
        background: 'hsl(var(--background))',
        foreground: 'hsl(var(--foreground))',
      }
    },
  },
};

tyrauber avatar May 29 '24 06:05 tyrauber

Closed as duplicate of #917

danstepanov avatar May 30 '24 15:05 danstepanov