Skip to content

How should the theme colors for dark mode and regular mode be defined? #15592

Closed Answered by wongjn
Sweet-KK asked this question in Help
Discussion options

You must be logged in to vote

You could do:

@import 'tailwindcss';
@variant dark (&:where(.dark, .dark *));
@theme {
  --color-secondary: rgba(244, 173, 12, 1);
}

@layer theme {
  [class~="dark"] {
    --color-secondary: rgba(215, 156, 50, 1);
  }
}

Or

@import 'tailwindcss';
@variant dark (&:where(.dark, .dark *));
@theme {
  --color-secondary: light-dark(rgba(244, 173, 12, 1), rgba(215, 156, 50, 1));

And then use color-scheme like:

<html class="scheme-light dark:scheme-dark dark">

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Sweet-KK
Comment options

You must be logged in to vote
1 reply
@wongjn
Comment options

Comment options

You must be logged in to vote
1 reply
@wongjn
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants