Skip to the content

The editor

Theming and branding

Make the editor look like part of your product. From least to most work:

  1. Your logo and starting theme, on the full editor.
  2. Theme and tokens: our interface, in your colours and font.
  3. ::part(): our interface, with deeper changes to its pieces.
  4. Your own interface on our commands: see Building your own ribbon.

The full editor shows a logo on its File button and on the File screen. Give it yours, in a version for each theme:

HTML
<dorvyn-editor
  server-url="/api/dorvyn"
  logo="/brand/logo.svg"
  logo-dark="/brand/logo-on-dark.svg"
  theme="light"
  animations="off"
></dorvyn-editor>
TSX
<DorvynEditor serverUrl="/api/dorvyn" logo="/brand/logo.svg" logoDark="/brand/logo-on-dark.svg" theme="light" animations={false} />
AttributeWhat it does
logoThe logo in the light theme. An SVG or a PNG, about 28 px tall; a wordmark works best
logo-darkThe logo in the dark theme (default: logo)
themelight or dark until the person chooses one in the editor (default: their system's setting)
animations="off"The File screen and theme changes don't animate, until the person turns animations on in Options

The person's own choices (theme, accent colour, animations, a collapsed ribbon) are kept in their browser and win over these defaults. People who ask their system for reduced motion get no animations either way.

The page itself (<dorvyn-document>) always renders like Word and can't be themed, so a document looks the same in your app, in Word and in the saved file. Your page's CSS doesn't reach into our interface either: each piece draws in its own shadow root.

The document itself is in your page (not in a shadow root, so selection, spell checking and assistive technology work as on any page), and your page's CSS doesn't change it either: the editor's rules for it outrank ordinary page rules, and what pages commonly set on every element (* { margin: 0 }, p { line-height: 2 }, ul { list-style: none }, img { display: block; max-width: 100% }, a body font or letter spacing) is set back to the browser's defaults inside it. Rules marked !important, or with two ids or more, still win: keep those away from dorvyn-document. Its colours come from the tokens below, as everywhere else.

Theme#

HTML
<dorvyn-ribbon theme="light"></dorvyn-ribbon>   <!-- "light", "dark", or "system" (the default) -->

system follows the person's operating system setting. theme works on <dorvyn-ribbon>, <dorvyn-tab> and <dorvyn-group>.

Design tokens#

Set them on the element, or on any ancestor (they inherit):

CSS
dorvyn-ribbon {
  --dorvyn-accent: #4c5fd5;            /* the interface's accent (active buttons, focus, the selected tab) */
  --dorvyn-font: "Inter", sans-serif;  /* the interface's font */
  --dorvyn-bg: #ffffff;                /* the ribbon's background */
  --dorvyn-surface: #ffffff;           /* menus */
  --dorvyn-text: #1a1a1a;              /* text */
  --dorvyn-border: #dcdcda;            /* borders */
}

Each token has a value for the light theme and one for the dark theme; setting it replaces both.

::part()#

PartOnWhat it is
tabs<dorvyn-ribbon>The tab strip
tab<dorvyn-ribbon>Each tab
ribbon<dorvyn-ribbon>, <dorvyn-tab>, <dorvyn-group>The panel holding the groups
button<dorvyn-command-button>The button
dialog<dorvyn-dialogs>The open dialog
pane<dorvyn-panes>Each open pane
titlebar, rail, statusbarthe full editor's title bar, sidebar, status barThe bar itself
backstage<dorvyn-backstage> (the full editor's File screen)The screen
CSS
dorvyn-ribbon::part(tabs) { justify-content: center; }
dorvyn-ribbon::part(tab) { text-transform: uppercase; letter-spacing: .04em; }
dorvyn-ribbon::part(ribbon) { border-radius: 12px; }

Placing our pieces#

Our interface comes apart, so you can use as much of it as you like, where you like:

You wantUse
The whole ribbon<dorvyn-ribbon>
Only some tabs, in your order<dorvyn-ribbon tabs="home,review">
One tab's groups, without the tab strip<dorvyn-tab name="home">
One group<dorvyn-group name="font">
One button<dorvyn-command-button command="bold">Bold</dorvyn-command-button>

Each finds its editor as the nearest <dorvyn-editor> around it, or the one its for attribute names (for="editor-id"), so a piece can sit anywhere on the page.

Options' Appearance and Accent color (and View's Light Mode / Dark Mode) set the theme and accent on every Dorvyn interface element on the page at once, and fire dorvyn-theme with "light" or "dark", so your page can follow:

JavaScript
document.addEventListener("dorvyn-theme", (e) => document.documentElement.dataset.theme = e.detail);

The accent colours people can choose are Mono, Periwinkle, Coral, Teal and Amber. --dorvyn-accent sets your own instead.

The full editor (an empty <dorvyn-editor>) uses the same theme and tokens throughout; its title bar, sidebar and status bar have the parts titlebar, rail and statusbar, and the frame around them is .dorvyn-frame in your page.