Put it in your app Styling and Tailwind
Styling and Tailwind
Two levels: recolour what comes with the editor with a few CSS variables, or draw the interface yourself with the headless hooks and whatever classes you like.
Recolour it
The variables are set on the element the editor is in, and the editor reads them: the canvas, the ruler and every bar, menu and dialog of the interface included. Nothing else changes.
Opening the editor…
The pages
The element the pages are in takes classes like any other.
<DocsSurface className="h-full bg-neutral-100 dark:bg-neutral-900" />Its rule (the colour behind the pages, its height, that it scrolls) is in a CSS layer of its own, put before any other, so the utilities of a framework that keeps them in layers, as Tailwind 4 does, win over it. The rest of the editor’s styles are not in a layer: they are for elements inside it, which your classes do not reach.
- --dx-canvas
- Behind the pages
- #efede8
- --dx-page-shadow
- The shadow of each page
- 0 1px 2px rgba(47,46,43,.08), 0 10px 28px -10px rgba(47,46,43,.22)
- --dx-selection
- The selection
- rgba(11,87,208,.2)
- --dx-caret
- The caret
- #000
- --dx-handle
- The handles on a touch screen
- #0b57d0
The page itself is white because paper is: a document says what colour its text is, and it takes white behind it for granted.
The ruler
Its own six, set on the same element or on any around it.
- --dx-ruler
- Behind it
- #fbfaf8
- --dx-ruler-line
- The line under it
- #e6e3dc
- --dx-ruler-margin
- The page outside the text
- #e6e3dc
- --dx-ruler-text
- The room of the text
- #fff
- --dx-ruler-ink
- Numbers and markers
- #5f5d58
- --dx-ruler-on
- The marker being dragged
- #0b57d0
The interface included
The toolbar, the menus, the side panel, the status bar, the dialogs and the bar beside the selection take eleven variables. Not set, each is the colour it always was.
- --dx-ui-bar
- Behind the toolbar and the status bar
- #fbfaf8
- --dx-ui-bg
- Behind menus, the panel and dialogs
- #fff
- --dx-ui-ink
- Text
- #2f2e2b
- --dx-ui-muted
- Icons, hints and headings of groups
- #5f5d58
- --dx-ui-line
- Borders and separators
- #e6e3dc
- --dx-ui-hover
- Under the pointer
- #f3f1ec
- --dx-ui-active
- What is on
- #e8f0fd
- --dx-ui-active-line
- The border of what is on
- #a8c7fa
- --dx-ui-accent
- Main buttons, links, focus rings
- #0b57d0
- --dx-ui-accent-hover
- A main button under the pointer
- #08398a
- --dx-ui-on-accent
- Text on the accent
- #fff
A dark theme comes with it. theme="dark" on DocsEditor or DocsProvider (editor.theme = 'dark' without React), or 'auto' to follow the system. It sets these variables to dark values whose text reads at 4.5:1, makes the tints of the menu and the reds that are not variables readable on dark, and is taken by the bars and menus shown outside the editor too. features={{ theme: true }} puts the choice in the menu, for the person to make. A variable set on the element still wins over it.
For a dark theme of your own, set color-scheme: dark on the same element as well: the lists that drop down from a select and the scroll bars are the browser’s, and it draws them dark only when told. A text colour of the document is the document’s, and the page stays white.
Where the pointer is a finger, the buttons grow: 38 pixels in the toolbar and the bar beside the selection, 34 in the status bar, 44 the items of the menu.
With the colours of the system forced on the page, as Windows does, what is on and what has the keyboard stay visible, whatever the theme.
The default colours keep text at 4.5:1 or more. A theme of your own has to as well: check its text against its backgrounds.
Pieces of your own
With the headless hooks each piece is yours to draw, one at a time: a hook gives what to show and what to do, and the JSX and its classes are yours. Six of them, each on a real document, with its whole file under it.
Opening the editor…
The smallest of all, a button:
function Bold() {
const { state, commands } = useDocs();
return (
<button
onClick={() => commands.toggleMark('bold')}
aria-pressed={state.bold}
className={`rounded px-2 py-1 font-bold ${state.bold ? 'bg-blue-600 text-white' : 'hover:bg-neutral-100'}`}
>
B
</button>
);
}With Tailwind
This site is Tailwind 4 in Next.js 16, with the editor in it. Nothing needs adding to the configuration.
- Tailwind’s reset gives every picture
max-width: 100%, which would squeeze the pictures of a document. The editor undoes it for its own. - The editor’s styles win over the reset’s, which Tailwind keeps in a layer, and your utilities win over the rule of the element the pages are in.