@uiw/codemirror-theme-material
v4.23.7
Published
Theme material for CodeMirror.
Downloads
193,743
Readme
Material Theme
This package implements the Material Dark theme for the CodeMirror code editor.
Install
npm install @uiw/codemirror-theme-material --save
import { EditorState } from '@codemirror/state';
import { javascript } from '@codemirror/lang-javascript';
import { material } from '@uiw/codemirror-theme-material';
const state = EditorState.create({
doc: 'my source code',
extensions: [material, javascript({ jsx: true })],
});
Using in React:
import { materialDark, materialDarkInit, materialLight, materialLightInit } from '@uiw/codemirror-theme-material';
// materialInit === materialDarkInit
// material === materialDark
<CodeMirror theme={material} />
<CodeMirror
theme={materialInit({
settings: {
caret: '#c6c6c6',
fontFamily: 'monospace',
}
})}
/>
API
import { CreateThemeOptions } from '@uiw/codemirror-themes';
export declare const defaultSettingsMaterial: CreateThemeOptions['settings'];
export declare const defaultSettingsMaterialDark: import('@uiw/codemirror-themes').Settings;
export declare const materialInit: (options?: Partial<CreateThemeOptions>) => import('@codemirror/state').Extension;
export declare const materialDarkInit: (options?: Partial<CreateThemeOptions>) => import('@codemirror/state').Extension;
export declare const materialDark: import('@codemirror/state').Extension;
export declare const material: import('@codemirror/state').Extension;
export declare const defaultSettingsMaterialLight: CreateThemeOptions['settings'];
export declare const materialLightInit: (
options?: Partial<CreateThemeOptions>,
) => import('@codemirror/state').Extension;
export declare const materialLight: import('@codemirror/state').Extension;
Usage
import CodeMirror from '@uiw/react-codemirror';
import { material } from '@uiw/codemirror-theme-material';
import { javascript } from '@codemirror/lang-javascript';
function App() {
return (
<CodeMirror
value="console.log('hello world!');"
height="200px"
theme={material}
extensions={[javascript({ jsx: true })]}
/>
);
}
export default App;
import { EditorView } from '@codemirror/view';
import { EditorState } from '@codemirror/state';
import { javascript } from '@codemirror/lang-javascript';
import { material } from '@uiw/codemirror-theme-material';
const state = EditorState.create({
doc: 'my source code',
extensions: [material, javascript({ jsx: true })],
});
const view = new EditorView({
parent: document.querySelector('#editor'),
state,
});
Contributors
As always, thanks to our amazing contributors!
Made with github-action-contributors.
License
Licensed under the MIT License.