Skip to content
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

Changing theme #253

Open
Lucjus opened this issue Sep 11, 2021 · 4 comments
Open

Changing theme #253

Lucjus opened this issue Sep 11, 2021 · 4 comments

Comments

@Lucjus
Copy link

Lucjus commented Sep 11, 2021

How can I change white default gh theme to a theme of my own choice? Is there any other way than overwriting css classes one by one?

@jaywcjlove
Copy link
Member

I have not customized other themes, and there is no other way.
@Lucjus

@sametweb
Copy link

If you are talking about the code block themes in preview, here is the way:

<MDEditor
  previewOptions={{ components: CodeBlock }}
  // other props
/>

CodeBlock.js

import {PrismAsync as SyntaxHighlighter} from 'react-syntax-highlighter'
import {vscDarkPlus} from 'react-syntax-highlighter/dist/cjs/styles/prism'

const CodeBlock = {
  code({children, className, ...props}) {
    let language = 'jsx'
	if (className) {
	  language = className.split('-')[1]
	}

	return (
	  <SyntaxHighlighter
	    wrapLines
	    wrapLongLines
	    showLineNumbers
	    style={vscDarkPlus}
	    PreTag='div'
	    language={language}
	    {...props}>
	    {String(children).replace(/\n$/, '')}
	    </SyntaxHighlighter>
	)
    },
}

export default CodeBlock

@Lucjus
Copy link
Author

Lucjus commented Dec 1, 2021

@sametweb That was it! Thank You!

@michaelnicol
Copy link

I need to use light theme for the website I am working on, and it's been an absolute pain dealing with the styling of the markdown editor. I used some CSS to target the components of the editor to make it light theme.

The problem is that I can't make the bolded text black instead of blue in the editor. Styles have no effect on the colors or font sizes of text in the editor. It's permanently stuck at 16 px font size, which is too small for my clients to read.

Because of this simple issue, I now have to find a different library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants