Overriding Theme CSS Variables
In this example, we override the editor's default theme CSS variables to create a red theme for both light and dark modes.
Relevant Docs:
import "@blocknote/core/fonts/inter.css";import { useCreateBlockNote } from "@blocknote/react";import { BlockNoteView } from "@blocknote/mantine";import "@blocknote/mantine/style.css";import "./styles.css";export default function App() { // Creates a new editor instance. const editor = useCreateBlockNote({ initialContent: [ { type: "paragraph", content: "Welcome to this demo!", }, { type: "paragraph", content: "Open up a menu or toolbar to see more of the red theme", }, { type: "paragraph", content: "Toggle light/dark mode in the page footer and see the theme change too", }, ], }); // Renders the editor instance using a React component. // Adds `data-theming-css-variables-demo` to restrict styles to only this demo. return <BlockNoteView editor={editor} data-theming-css-variables-demo />;}/* Base theme */.bn-root[data-theming-css-variables-demo][data-color-scheme] { --bn-text-color-primary: #222222; --bn-background-color-editor: #ffeeee; --bn-text-color-menu: #ffffff; --bn-background-color-menu: #9b0000; --bn-text-color-tooltip: #ffffff; --bn-background-color-tooltip: #b00000; --bn-text-color-hovered: #ffffff; --bn-background-color-hovered: #b00000; --bn-text-color-selected: #ffffff; --bn-background-color-selected: #c50000; --bn-text-color-disabled: #9b0000; --bn-background-color-disabled: #7d0000; --bn-shadow-default: 0 4px 12px #640000; --bn-shadow-subtle: 0 2px 6px #870000; --bn-border-color: #870000; --bn-text-color-muted: #bababa; --bn-border-color-strong: #bababa; --bn-focus-ring-color: #bababa; --bn-radius-small: 2px; --bn-radius-medium: 4px; --bn-radius-large: 6px; --bn-font-family-default: Helvetica Neue, sans-serif;}/* Changes for dark mode */.bn-root[data-theming-css-variables-demo][data-color-scheme="dark"] { --bn-text-color-primary: #ffffff; --bn-background-color-editor: #9b0000; --bn-text-color-muted: #ffffff; --bn-border-color-strong: #ffffff; --bn-focus-ring-color: #ffffff;}/// <reference types="vite-plus/client" />