Skip to content

Dark Mode (Tailwind) not working  #150

@Subham-Maity

Description

@Subham-Maity

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:

import { DiscussionEmbed } from "disqus-react";
import { useTheme } from "next-themes";
import { useRouter } from "next/router";

const Disqus = ({ className }: { className?: string }) => {
  const { asPath } = useRouter();
  const origin =
    typeof window !== "undefined" && window.location.origin
      ? window.location.origin
      : "";

  const url = `${origin}${asPath}`;
  console.log(url, "url");
  const { theme } = useTheme();

  return (
    <div className={className} key={theme}>
      <DiscussionEmbed
        shortname="https-abcdefg-vercel-app"
        config={
          {
            url,
            identifier: url,
            title: "abcdefg",
            language: "en_US",
            sso: {
              name: "SampleNews",
            },
            colorScheme: theme === "dark" ? "dark" : "light",
          } as any
        }
      />
    </div>
  );
};

export default Disqus;
//Parent 
<div className="w-[640px] ml-4 md:ml-64 lg:ml-96">
<DisqusComments className="bg-white dark:bg-[#242525] p-5" />
</div>

Dark Mode
image
Light Mode
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions