Skip to content

Apply dark theme to prisms #436

@patrick91

Description

@patrick91

Hi there 👋 is there a way to change the theme for prism based on the color mode?

This is what I tried, but didn't work:

import prismTheme from "@theme-ui/prism/presets/night-owl-light.json";
import prismThemeDark from "@theme-ui/prism/presets/night-owl.json";

export default {
  useColorSchemeMediaQuery: true,
  colors: {
    text: "#000",
    background: "#fff",

    modes: {
      dark: {
        text: "#fff",
        background: "#000",
        primary: "#0cf",
      },
    },
  },
  
  styles: {
    pre: {
      fontFamily: "monospace",
      overflowX: "auto",
      padding: 3,
      code: {
        color: "inherit",
      },
      ...prismTheme,
      mode: {
        dark: {
          ...prismThemeDark,
        },
      },
    },
  }
};

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