question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Apply dark theme to prisms

See original GitHub issue

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,
        },
      },
    },
  }
};

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lachlanjccommented, Feb 22, 2021

@ahmedelq Here’s a link! https://dev.theme-ui.com/guides/syntax-highlighting/

You can’t change the CSS of a component in dark mode from your theme. However, you can set colors to use for syntax highlighting inside each color mode, then refer to that color name in your syntax highlighting code, & they will update with your color modes.

1reaction
patrick91commented, Nov 5, 2019

Oh, this is cool! Sorry I didn’t notice 😃 Thanks a lot!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dark theme for Prism and 302+ apps — Dracula
Dracula is a color scheme for code editors and terminal emulators, including Prism and 302+ other apps. Check the instructions to learn how...
Read more >
Modifying UI Settings (Prism Central) - Nutanix Support Portal
Prism Theme (Dark Mode). Click to enlarge Prism Dark Background, High Contrast View. Select Auto (OS defined) to apply background themes defined in...
Read more >
Code highlighting (light & dark mode) with Prism.js - CodePen
A pen to highlight embedded code examples using Prism.js with a dark or light mode theme. Reference the CSS and JavaScript of this...
Read more >
prism-theme-one-light-dark - npm
If the web application supports toggling between light and dark themes, then to inject the corresponding Prism theme, use raw-loader , a Webpack ......
Read more >
theme-ui/prism
To theme the prism styles based on the colors defined in your theme.colors object, use the theme-ui preset, which will use the following...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found