Themes for monaco editor in web browser
npm install monaco-themesSee extended demo at https://editor.bitwiser.in
A list of theme definitions to be used with monaco-editor in browser. See minimal demo
``sh`
npm install monaco-themesor
pnpm add monaco-themesor
yarn add monaco-themes
#### API
##### Using ESM (Recommended)
`js
import { parseTmTheme } from 'monaco-themes';
const tmThemeString = / read using FileReader /
const themeData = parseTmTheme(tmThemeString);
monaco.editor.defineTheme('mytheme', themeData);
monaco.editor.setTheme('mytheme');
`
##### Using CommonJS
`js
const { parseTmTheme } = require('monaco-themes');
const tmThemeString = / read using FileReader /
const themeData = parseTmTheme(tmThemeString);
monaco.editor.defineTheme('mytheme', themeData);
monaco.editor.setTheme('mytheme');
`
##### Using
`
#### Directly using themes
##### With modern bundlers (Vite, Webpack, etc.)
`js
const monaco =
/ import monaco /
import('monaco-themes/themes/Monokai.json').then((data) => {
monaco.editor.defineTheme('monokai', data.default || data);
monaco.editor.setTheme('monokai');
});
`
##### Using fetch
Download this repository and extract and save the themes directory in your project.
`js
/ load monaco /
fetch('/themes/Monokai.json')
.then((data) => data.json())
.then((data) => {
monaco.editor.defineTheme('monokai', data);
monaco.editor.setTheme('monokai');
});
`
This project uses modern tooling:
- pnpm for package management
- Vite for local development server
- tsdown for building the library
- TypeScript for type safety
- Node.js v22+ with native TypeScript support
#### Setup
`sh`
pnpm install
#### Available Scripts
`shStart development server with Vite
pnpm dev
#### Building
The library is built with tsdown and outputs:
- ESM (
dist/index.js) - ES Module format
- CJS (dist/index.cjs) - CommonJS format
- IIFE (dist/monaco-themes.js`) - Browser-ready UMD-like formatAll builds include TypeScript declarations and source maps.
MIT