4.23.10 • Published 4 months ago

@uiw/codemirror-themes v4.23.10

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Custom Codemirror Themes

Buy me a coffee npm version

Themes for CodeMirror.

Install

npm install @uiw/codemirror-themes --save

Usage

import { EditorView } from '@codemirror/view';
import { EditorState } from '@codemirror/state';
import { createTheme } from '@uiw/codemirror-themes';
import { javascript } from '@codemirror/lang-javascript';
import { tags as t } from '@lezer/highlight';

const myTheme = createTheme({
  theme: 'light',
  settings: {
    background: '#ffffff',
    backgroundImage: '',
    foreground: '#75baff',
    caret: '#5d00ff',
    selection: '#036dd626',
    selectionMatch: '#036dd626',
    lineHighlight: '#8a91991a',
    gutterBorder: '1px solid #ffffff10',
    gutterBackground: '#fff',
    gutterForeground: '#8a919966',
  },
  styles: [
    { tag: t.comment, color: '#787b8099' },
    { tag: t.variableName, color: '#0080ff' },
    { tag: [t.string, t.special(t.brace)], color: '#5c6166' },
    { tag: t.number, color: '#5c6166' },
    { tag: t.bool, color: '#5c6166' },
    { tag: t.null, color: '#5c6166' },
    { tag: t.keyword, color: '#5c6166' },
    { tag: t.operator, color: '#5c6166' },
    { tag: t.className, color: '#5c6166' },
    { tag: t.definition(t.typeName), color: '#5c6166' },
    { tag: t.typeName, color: '#5c6166' },
    { tag: t.angleBracket, color: '#5c6166' },
    { tag: t.tagName, color: '#5c6166' },
    { tag: t.attributeName, color: '#5c6166' },
  ],
});

const state = EditorState.create({
  doc: 'my source code',
  extensions: [myTheme, javascript({ jsx: true })],
});

const view = new EditorView({
  parent: document.querySelector('#editor'),
  state,
});
import CodeMirror from '@uiw/react-codemirror';
import { createTheme } from '@uiw/codemirror-themes';
import { javascript } from '@codemirror/lang-javascript';
import { tags as t } from '@lezer/highlight';

const myTheme = createTheme({
  theme: 'light',
  settings: {
    background: '#ffffff',
    backgroundImage: '',
    foreground: '#75baff',
    caret: '#5d00ff',
    selection: '#036dd626',
    selectionMatch: '#036dd626',
    lineHighlight: '#8a91991a',
    gutterBackground: '#fff',
    gutterForeground: '#8a919966',
  },
  styles: [
    { tag: t.comment, color: '#787b8099' },
    { tag: t.variableName, color: '#0080ff' },
    { tag: [t.string, t.special(t.brace)], color: '#5c6166' },
    { tag: t.number, color: '#5c6166' },
    { tag: t.bool, color: '#5c6166' },
    { tag: t.null, color: '#5c6166' },
    { tag: t.keyword, color: '#5c6166' },
    { tag: t.operator, color: '#5c6166' },
    { tag: t.className, color: '#5c6166' },
    { tag: t.definition(t.typeName), color: '#5c6166' },
    { tag: t.typeName, color: '#5c6166' },
    { tag: t.angleBracket, color: '#5c6166' },
    { tag: t.tagName, color: '#5c6166' },
    { tag: t.attributeName, color: '#5c6166' },
  ],
});

function App() {
  return (
    <CodeMirror
      value="console.log('hello world!');"
      height="200px"
      theme={myTheme}
      extensions={[javascript({ jsx: true })]}
      onChange={(value, viewUpdate) => {
        console.log('value:', value);
      }}
    />
  );
}
export default App;

Themes

abcdef

android studio

atom one

aura

bbedit

bespin

darcula

dracula

duotone

eclipse

github

gruvbox

material

noctis-lilac

nord

okaidia

solarized

sublime

tokyo-night

tokyo-night-day

tokyo-night-storm

vscode

xcode

Props

import { Extension } from '@codemirror/state';
import { TagStyle } from '@codemirror/language';
export interface CreateThemeOptions {
  /**
   * Theme inheritance. Determines which styles CodeMirror will apply by default.
   */
  theme: Theme;
  /**
   * Settings to customize the look of the editor, like background, gutter, selection and others.
   */
  settings: Settings;
  /** Syntax highlighting styles. */
  styles: TagStyle[];
}
type Theme = 'light' | 'dark';
export interface Settings {
  /** Editor background color. */
  background?: string;
  /** Editor background image. */
  backgroundImage?: string;
  /** Default text color. */
  foreground?: string;
  /** Caret color. */
  caret?: string;
  /** Selection background. */
  selection?: string;
  /** Selection match background. */
  selectionMatch?: string;
  /** Background of highlighted lines. */
  lineHighlight?: string;
  /** Gutter background. */
  gutterBackground?: string;
  /** Text color inside gutter. */
  gutterForeground?: string;
  /** Text active color inside gutter. */
  gutterActiveForeground?: string;
  /** Gutter right border color. */
  gutterBorder?: string;
  /** set editor font */
  fontFamily?: string;
}
export declare const createTheme: ({ theme, settings, styles }: CreateThemeOptions) => Extension;
export default createTheme;

Related

Contributors

As always, thanks to our amazing contributors!

Made with github-action-contributors.

License

Licensed under the MIT License.

@infinitebrahmanuniverse/nolb-_uivzcodethe-rest-api-client@conda-store/conda-store-ui@coursebuilder/uitripdocstripdocs-js-sdkwc-studio@fe-free/core@huomu/core@electric-sql/pglite-repl@fuse-finance/ui-library@libsqlstudio/gui@markflowy/editor@neon.id/field@sanity/code-input@scalar/use-codemirror@penrose/componentspalm-editorreact-haku-code-lablibsql-studio-guimdgjx-web@waii-ai/widgets@uiw/react-markdown-editor@uiw/codemirror-theme-darcula@uiw/codemirror-theme-dracula@uiw/codemirror-theme-duotone@uiw/codemirror-theme-eclipse@uiw/codemirror-theme-github@uiw/codemirror-theme-gruvbox-dark@uiw/codemirror-theme-kimbie@uiw/codemirror-theme-andromeda@uiw/codemirror-theme-atomone@uiw/codemirror-theme-aura@uiw/codemirror-theme-basic@uiw/codemirror-theme-bbedit@uiw/codemirror-theme-bespin@uiw/codemirror-theme-console@uiw/codemirror-theme-copilot@uiw/codemirror-theme-noctis-lilac@uiw/codemirror-theme-nord@uiw/codemirror-theme-okaidia@uiw/codemirror-theme-quietlight@uiw/codemirror-theme-red@uiw/codemirror-theme-solarized@uiw/codemirror-theme-abcdef@uiw/codemirror-theme-abyss@uiw/codemirror-theme-material@uiw/codemirror-theme-monokai@uiw/codemirror-theme-monokai-dimmed@uiw/codemirror-theme-androidstudio@uiw/codemirror-theme-white@uiw/codemirror-theme-xcode@uiw/codemirror-themes-all@uiw/codemirror-theme-sublime@uiw/codemirror-theme-tokyo-night@uiw/codemirror-theme-tokyo-night-day@uiw/codemirror-theme-tokyo-night-storm@uiw/codemirror-theme-tomorrow-night-blue@uiw/codemirror-theme-vscode@vizhub/codemirror-theme@use-gpu/inspect-gpu@zalastax/nolb-_ui@zhongyiio/react-markdown-editoracciojob-packagescallsmithcarbon-react-code-mirrorcarbon-addons-iot-reactcodemirror-theme-vitessebql-querier@strudel.cycles/react@srcbook/components
4.23.10

4 months ago

4.23.8

5 months ago

4.23.9

4 months ago

4.23.7

7 months ago

4.23.6

8 months ago

4.23.4

9 months ago

4.23.5

9 months ago

4.23.1

10 months ago

4.23.2

10 months ago

4.23.3

9 months ago

4.23.0

12 months ago

4.22.2

1 year ago

4.22.1

1 year ago

4.22.0

1 year ago

4.21.25

1 year ago

4.21.24

1 year ago

4.21.23

1 year ago

4.21.22

1 year ago

4.21.11

2 years ago

4.21.10

2 years ago

4.21.13

2 years ago

4.21.12

2 years ago

4.21.19

2 years ago

4.21.18

2 years ago

4.21.15

2 years ago

4.21.14

2 years ago

4.21.17

2 years ago

4.21.16

2 years ago

4.21.9

2 years ago

4.21.8

2 years ago

4.21.21

2 years ago

4.21.20

2 years ago

4.21.6

2 years ago

4.21.7

2 years ago

4.21.4

2 years ago

4.21.5

2 years ago

4.21.1

2 years ago

4.21.2

2 years ago

4.21.3

2 years ago

4.21.0

2 years ago

4.20.2

2 years ago

4.20.3

2 years ago

4.20.4

2 years ago

4.20.0

2 years ago

4.20.1

2 years ago

4.19.14

2 years ago

4.19.13

2 years ago

4.19.12

2 years ago

4.19.11

2 years ago

4.19.10

2 years ago

4.19.16

2 years ago

4.19.15

2 years ago

4.19.8

2 years ago

4.19.9

2 years ago

4.19.5

3 years ago

4.19.6

2 years ago

4.19.7

2 years ago

4.19.3

3 years ago

4.19.4

3 years ago

4.19.0

3 years ago

4.18.1

3 years ago

4.19.1

3 years ago

4.18.2

3 years ago

4.19.2

3 years ago

4.16.0

3 years ago

4.17.0

3 years ago

4.18.0

3 years ago

4.17.1

3 years ago

4.15.0

3 years ago

4.14.1

3 years ago

4.13.2

3 years ago

4.15.1

3 years ago

4.14.2

3 years ago

4.12.4

3 years ago

4.14.3

3 years ago

4.13.0

3 years ago

4.14.0

3 years ago

4.13.1

3 years ago

4.12.3

3 years ago

4.12.2

3 years ago

4.11.5

3 years ago

4.11.6

3 years ago

4.12.0

3 years ago

4.12.1

3 years ago

4.11.4

3 years ago

4.9.4

3 years ago

4.9.3

3 years ago

4.9.6

3 years ago

4.9.5

3 years ago

4.9.2

3 years ago

4.11.0

3 years ago

4.10.1

3 years ago

4.11.1

3 years ago

4.10.2

3 years ago

4.11.2

3 years ago

4.10.3

3 years ago

4.11.3

3 years ago

4.10.4

3 years ago

4.10.0

3 years ago

4.9.1

3 years ago

4.9.0

3 years ago

4.8.1

3 years ago