Styling CodeMirror blocks #930
-
|
I would like to pick a theme for my CodeMirror blocks, as specified in https://codemirror.net/examples/styling/#themes. There doesn't seem to be anything exposed for this, and no documentation exists. All I could find was an old thread that wasn't helpful at all. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Use the import { EditorView } from '@codemirror/view'
codeMirrorPlugin({
codeBlockLanguages: { js: 'JavaScript', css: 'CSS' },
autoLoadLanguageSupport: true,
codeMirrorExtensions: [
EditorView.theme({
'&': {
backgroundColor: '#111827',
color: '#e5e7eb'
},
'.cm-gutters': {
backgroundColor: '#0f172a',
color: '#94a3b8'
}
})
]
})One caveat: MDXEditor's current |
Beta Was this translation helpful? Give feedback.
Use the
codeMirrorExtensionsoption. CodeMirror themes are extensions, so you can pass anEditorView.theme(...)extension throughcodeMirrorPlugin:One caveat: MDXEditor's current
CodeMirrorEditoralso adds its built-in light theme, so if you are overriding the same selectors you may need more specific …