Skip to content

Repository files navigation

CodeMirror 6 Themes Logo

Build Main Status Latest Release Total npm downloads of the theme bundle
GitHub contributors Dependency status for repo GitHub License
Stars Forks

A library of custom themes for CodeMirror 6.

@fsegurai/codemirror-theme-bundle is a collection of themes to enhance CodeMirror 6 editor, making it visually engaging and adaptable to different coding styles and user preferences.


Table of contents

Installation

@fsegurai/codemirror-theme-bundle

To add @fsegurai/codemirror-theme-bundle along with CodeMirror 6 to your package.json use the following commands.

bun install @fsegurai/codemirror-theme-bundle codemirror@^6.0.0 --save

Using a Theme

Import the desired theme from the package and apply it to your CodeMirror instance as shown below.

import {EditorView, basicSetup} from 'codemirror'
import {markdown} from '@codemirror/lang-markdown'
import {bundle} from '@fsegurai/codemirror-theme-bundle'

let editor = new EditorView({
	doc: '# Hello World',
	extensions: [
		basicSetup,
		markdown(),
		bundle
	],
	parent: document.body
})

Every theme package depends on @fsegurai/codemirror-theme-core (installed automatically). Without a bundler (import maps, CDN), map the core too: the theme builds import it.

Read the CodeMirror documentation for more details about themes. The versioned documentation of this release is in docs/6.32.0.

Custom and CSS-Variable Themes

Every theme is built by @fsegurai/codemirror-theme-core, which every theme package depends on. It is public, so a theme of your own gets the same complete structure:

  • defineTheme(definition) turns a ThemeDefinition (a complete UiPalette plus syntax roles) into { extension, theme, highlightStyle, mergeStyles }.
  • cssVariableTheme(options?) is one theme whose colors are CSS custom properties with fallbacks (var(--cm-background, #ffffff), var(--cm-syntax-keyword, #cf222e), …), so a single extension follows the page's light, dark or high-contrast CSS. Pass { dark: true } on dark pages (CSS variables cannot tell CodeMirror the editor is dark), prefix to rename the variables and variables / fallbacks to map them to your own tokens.
import { cssVariableTheme } from '@fsegurai/codemirror-theme-core';

const extensions = [basicSetup, cssVariableTheme({ dark: false }).extension];
:root { --cm-background: var(--app-surface); --cm-foreground: var(--app-text); --cm-accent: var(--app-primary); }

The core README lists every variable it reads (14 base colors, then per-part and per-syntax-role overrides), its options, and an Angular example. Both functions are also exported by @fsegurai/codemirror-theme-bundle.

Available Themes

Theme Package Version Downloads
All - Bundle @fsegurai/codemirror-theme-bundle npm downloads
Core (builder) @fsegurai/codemirror-theme-core npm downloads
Abcdef @fsegurai/codemirror-theme-abcdef npm downloads
Abyss @fsegurai/codemirror-theme-abyss npm downloads
Android Studio @fsegurai/codemirror-theme-android-studio npm downloads
Andromeda @fsegurai/codemirror-theme-andromeda npm downloads
Basic Dark @fsegurai/codemirror-theme-basic-dark npm downloads
Basic Light @fsegurai/codemirror-theme-basic-light npm downloads
Catppuccin Latte @fsegurai/codemirror-theme-catppuccin-latte npm downloads
Catppuccin Mocha @fsegurai/codemirror-theme-catppuccin-mocha npm downloads
Cobalt2 @fsegurai/codemirror-theme-cobalt2 npm downloads
Dracula @fsegurai/codemirror-theme-dracula npm downloads
Forest @fsegurai/codemirror-theme-forest npm downloads
GitHub Dark @fsegurai/codemirror-theme-github-dark npm downloads
GitHub Light @fsegurai/codemirror-theme-github-light npm downloads
Gruvbox Dark @fsegurai/codemirror-theme-gruvbox-dark npm downloads
Gruvbox Light @fsegurai/codemirror-theme-gruvbox-light npm downloads
High Contrast Dark @fsegurai/codemirror-theme-high-contrast-dark npm downloads
High Contrast Light @fsegurai/codemirror-theme-high-contrast-light npm downloads
Material Dark @fsegurai/codemirror-theme-material-dark npm downloads
Material Light @fsegurai/codemirror-theme-material-light npm downloads
Material Ocean @fsegurai/codemirror-theme-material-ocean npm downloads
Monokai @fsegurai/codemirror-theme-monokai npm downloads
Nord @fsegurai/codemirror-theme-nord npm downloads
One Dark @fsegurai/codemirror-theme-one-dark npm downloads
Palenight @fsegurai/codemirror-theme-palenight npm downloads
Rosé Pine Dawn @fsegurai/codemirror-theme-rose-pine-dawn npm downloads
Solarized Dark @fsegurai/codemirror-theme-solarized-dark npm downloads
Solarized Light @fsegurai/codemirror-theme-solarized-light npm downloads
Synthwave 84 @fsegurai/codemirror-theme-synthwave-84 npm downloads
Tokyo Night Day @fsegurai/codemirror-theme-tokyo-night-day npm downloads
Tokyo Night Storm @fsegurai/codemirror-theme-tokyo-night-storm npm downloads
Volcano @fsegurai/codemirror-theme-volcano npm downloads
VS Code Light @fsegurai/codemirror-theme-vscode-light npm downloads
VS Code Dark @fsegurai/codemirror-theme-vscode-dark npm downloads

Demo Application

To see all themes in action, check out the demo: https://fsegurai.github.io/codemirror-themes.

To set up the demo locally:

git clone https://github.com/fsegurai/codemirror-themes.git
bun install
bun start

This will serve the application locally at http://[::1]:8000.

License

Licensed under MIT.

Releases

Packages

Used by

Contributors

Languages