Fixing This Issue (Light/Dark Theme Backgrounds) #117
megh-bari
announced in
Announcements
Replies: 1 comment
-
|
Awesome! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
A lot of people have mentioned in GitHub issues that they want both light and dark mode support for backgrounds.
Here’s how you can do it:
Instead of using my fixed color scheme, you can append your shadcn/tweakcn theme variables like this (see example below).
Rather than hardcoding colors, use CSS custom properties (variables) so that your background automatically adapts to your theme and stays consistent.
Handling Heavy Colors in Gradients
You can use
var(--primary)directly, but that will give you the exact raw color, which can sometimes look too intense.Instead, you can use CSS
oklch()color manipulation:This approach lets you:
calc(l - 0.1)c h)/ 0.20This makes the gradient adapt nicely to your theme without being overpowering.
Final Thoughts
Use whichever method works best for your project it’s not too complex once you try it.
And honestly, with AI tools available, you can easily generate the same approach for vanilla CSS too.
Thanks for reading! Hope this clears things up.
Feel free to share how you implemented it in your project would love to see it.
Example Demo:
Beta Was this translation helpful? Give feedback.
All reactions