Detect when dark mode

If you implemented storybook-dark-mode and you want to detect the current color mode

import React from "react";
import { DocsContainer as BaseContainer } from "@storybook/addon-docs/blocks";
import { useDarkMode } from "storybook-dark-mode";
import { themes } from "@storybook/theming";

export const DocsContainer = ({ children, context }) => {
  const dark = useDarkMode();

  return (
     <div>
        {dark ? "It's dark" : "it's light"}
     </div>
  );
};

Last updated