Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 1.48 KB

README.md

File metadata and controls

39 lines (31 loc) · 1.48 KB

CodeMirror Color Picker

Run on Replit badge NPM version badge

A CodeMirror extension that adds a color picker input next to CSS color values.

preview

Usage

import { basicSetup } from 'codemirror';
import { EditorState } from '@codemirror/state';
import { EditorView } from '@codemirror/view';
import { css } from '@codemirror/lang-css';
import { colorPicker, wrapperClassName } from '@replit/codemirror-css-color-picker';

new EditorView({
  parent: document.querySelector('#editor'),
  state: EditorState.create({
    doc: '.wow {\n  color: #fff;\n}',
    extensions: [
      basicSetup,
      css(),
      colorPicker,
      EditorView.theme({
        [`.${wrapperClassName}`]: {
          outlineColor: 'transparent',
        },
      }),
    ],
  }),
});

Todos

  • Investigate solutions for alpha values. input[type="color"] doesn't support alpha values, we could show another number input next to it for the alpha value.