-
Notifications
You must be signed in to change notification settings - Fork 46
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
Dark Mode (Tailwind) not working #150
Comments
@Subham-Maity same issue here. Did you fixed it? |
@TharinduX Yes ! The only solution to this issue is to set up custom CSS. I’m using Next.js, so by default, I get When you switch off the light mode using this method, the when you set up a switcher component (or any other type of theme switcher), it changes the current theme being used by your website. Since the |
@Subham-Maity Thanks! It fixed my dark mode issue. Im also using Next.js But still some issues in Light mode. |
Finally fixed it. Thanks @Subham-Maity I just needed to add the |
I have a workaround but it is not perfect. Yes, My issue is the transition of the background and Disqus if set to auto theme is picking the wrong background color. I first thought to delay the component render until the theme is ready but couldn't get it to work - server side rendering complaint about it. In my layout component I have the following transition class: // RootLayout
return (
<div className={clsx('bg-main-light text-main dark:bg-main dark:text-main-light transition-colors duration-500 ', inter.className)}>
{ children } /* <------ Disqus comments will be rendered here */
</div>) So I have added a wrapper which is immediately set to the right background color. Then Disqus theme is working. Here is my Code: "use client"
import { DiscussionEmbed } from "disqus-react";
import { useTheme } from "next-themes";
interface CommentsProps {
title: string;
}
const Comments = ({ title }: CommentsProps) => {
const { theme } = useTheme();
const url = typeof window !== 'undefined' && window.location.href
? window.location.href
: '';
const slug = url.split("/").slice(-1)[0]; // attention slug must be the last part
return (<div className="bg-main-light dark:bg-main pt-4">
{/* Setting bg here fixes transition issue at theme toggle - not perfect causes short flicker on comments section
but colors in Disqus are correct */}
<DiscussionEmbed
key={theme}
shortname='ydecide-blog'
config={
{
url,
identifier: slug as string,
title: title
}
}
/>
</div>)
}
export default Comments Here is the example screen recording, showing the short flicker during transition. |
I am using tailwind
dark:
class and"next-themes": "^0.2.1"
to enable dark mode for my components. However, it does not work for Disqus Component. I have tried applying the dark class inside and outside the component, but it still does not change the color scheme. It works fine in light mode though. How can I fix this issue?Here is my code for the component:
Dark Mode
Light Mode
The text was updated successfully, but these errors were encountered: