Skip to content

Theming

The editor follows the system’s light or dark preference. Force one with data-theme="light" or data-theme="dark" on the editor or any ancestor, such as <html>, or with the dark-theme class on the editor. The nearest one wins.

The editor’s colours are CSS variables on its root element and its popups. They follow the Radix semantic aliases:

.my-editor {
--accentSolid: tomato;
--accentText: firebrick;
--baseBg: #f6f6f6;
--basePageBg: white;
--admonitionTipBg: #e0f7fa;
}

Pass the class to the editor with class="my-editor"; it also applies to the popup container. The scales are --accentBase to --accentTextContrast and --baseBase to --baseTextContrast, plus the admonition colours. To use another Radix scale, import its CSS and map the variables.

Class Element
sveltedown The root element.
sveltedown-popup-container The container of popups and dialogs.
sveltedown-toolbar The toolbar.
sveltedown-root-contenteditable The rich text area.
sveltedown-diff-source-wrapper The wrapper of the three views, with sveltedown-rich-text-editor, sveltedown-source-editor and sveltedown-diff-editor.
sveltedown-select-content Dropdowns.

Other classes, which start with sd-, are internal and can change.

contentEditableClass sets a class on the editable area, for typography such as Tailwind’s prose:

<MarkdownEditor markdown="Hello **world**" contentEditableClass="prose" />

Keep its selectors specific: the area also contains the editor’s own UI, such as table controls and code blocks. lexicalTheme replaces the classes of the formatted text.