blockcn

Theming

CSS variables, class names, and data attributes for styling the editor.

Chrome, selection, callouts, and the code theme read --blockcn-* variables. Each one falls back to a shadcn token or a built-in colour, so an app that already themes shadcn picks that up. Override a variable on :root or .dark to change the editor without editing its stylesheet.

Editor, Editor.Frame, and Editor.Content take className and classNames. classNames is a string of extra classes for that part, or { root, frame, content } on Editor (a frame or content object key applies to that part). The root wrapper is display: contents.

PartAttribute
Rootdata-blockcn-root
Framedata-blockcn-frame
Contentdata-blockcn-content
Chromedata-blockcn-chrome
Outlinedata-blockcn-outline

Variables

Light value first. A second value is the .dark override.

VariableDefault
--blockcn-surfacevar(--background)
--blockcn-surface-mutedvar(--muted)
--blockcn-foregroundvar(--foreground)
--blockcn-mutedvar(--muted-foreground)
--blockcn-bordervar(--border)
--blockcn-ringvar(--ring)
--blockcn-primaryvar(--primary)
--blockcn-popovervar(--popover)
--blockcn-popover-foregroundvar(--popover-foreground)
--blockcn-selectionHighlight
--blockcn-find-matchrgb(250 204 21 / 55%) / rgb(250 204 21 / 32%)
--blockcn-find-currentrgb(251 146 60 / 75%) / rgb(251 146 60 / 55%)
--blockcn-cell-selectionrgb(59 130 246 / 12%)
--blockcn-column-resize#3b82f6
--blockcn-drop-cursorvar(--primary)
--blockcn-handlevar(--foreground)
--blockcn-caret-label#fff
--blockcn-shadowrgb(0 0 0 / 12%)
--blockcn-commentrgb(250 204 21 / 26%) / rgb(250 204 21 / 18%) (comments add-on)
--blockcn-comment-activergb(250 204 21 / 55%) / rgb(250 204 21 / 38%) (comments add-on)
--blockcn-version-insertrgb(34 197 94 / 28%) / rgb(34 197 94 / 22%) (versions add-on)
--blockcn-version-deletergb(239 68 68 / 28%) / rgb(239 68 68 / 22%) (versions add-on)
--blockcn-suggestion-insert#15803d (suggestions add-on; an author colour overrides it)
--blockcn-suggestion-delete#b91c1c (suggestions add-on; an author colour overrides it)
--blockcn-code-keyword#d73a49 / #ff7b72
--blockcn-code-string#032f62 / #a5d6ff
--blockcn-code-comment#6a737d / #8b949e
--blockcn-code-literal#005cc5 / #79c0ff
--blockcn-code-function#6f42c1 / #d2a8ff
--blockcn-text-gray#787774 / #9b9a97
--blockcn-text-brown#9f6b53 / #ba856f
--blockcn-text-orange#d9730d / #ffa344
--blockcn-text-yellow#cb912f / #ffdc49
--blockcn-text-green#448361 / #4dab9a
--blockcn-text-blue#337ea9 / #529cca
--blockcn-text-purple#9065b0 / #9a6dd7
--blockcn-text-pink#c14c8a / #e255a1
--blockcn-text-red#d44c47 / #ff7369
--blockcn-highlight-gray#f1f1ef / #373737
--blockcn-highlight-brown#f4eeee / #4a3228
--blockcn-highlight-orange#fbecdd / #5c3b23
--blockcn-highlight-yellow#fbf3db / #564328
--blockcn-highlight-green#edf3ec / #243d30
--blockcn-highlight-blue#e7f3f8 / #1a3a4c
--blockcn-highlight-purple#f6f3f9 / #3c2d49
--blockcn-highlight-pink#faf1f5 / #4e2c3c
--blockcn-highlight-red#fdebec / #522e2a

Text and highlight colours are stored on marks as var(--blockcn-text-red), so a theme change repaints existing text.

Dark mode

Put the overrides next to the rest of the app's dark theme. This example only changes the surface, the text, and the code keywords; every other variable keeps the default above.

.dark {
  --blockcn-surface: #0c0c0c;
  --blockcn-foreground: #f4f4f5;
  --blockcn-border: #27272a;
  --blockcn-code-keyword: #ff7b72;
}
<div className="dark">
  <Editor editor={editor}>
    <Editor.Frame className="rounded-lg border">
      <Editor.Content classNames="min-h-[70vh]" />
    </Editor.Frame>
  </Editor>
</div>

On this page