<visual-novel> is the box your whole game lives in. Every screen (the main menu, the game itself, the settings, the save and load screens) is an element inside it, and the engine looks for those screens there. It draws nothing of its own: whatever you write inside it in index.html stays as you wrote it.

Mio on the left and Yui on the right in front of the Palacio de Bellas Artes, with the text box and the quick menu at the bottom
Everything on screen is inside the visual-novel element

Tag <visual-novel>
Where it lives In index.html, inside <div id="monogatari"> (the starter game has it)
Built on Component
Source src/components/visual-novel/

Where it lives

A Monogatari game is a web page first. The starter game’s index.html has this block in its <body>:

<div id="monogatari">
  <visual-novel>
    <language-selection-screen></language-selection-screen>
    <loading-screen></loading-screen>
    <main-screen>
      <main-menu></main-menu>
    </main-screen>
    <game-screen>
      <dialog-log></dialog-log>
      <text-box></text-box>
      <quick-menu></quick-menu>
    </game-screen>
    <gallery-screen></gallery-screen>
    <credits-screen></credits-screen>
    <load-screen></load-screen>
    <save-screen></save-screen>
    <settings-screen></settings-screen>
    <help-screen></help-screen>
  </visual-novel>
</div>

js/main.js starts the engine with monogatari.init('#monogatari'), which points it at the outer <div>. From then on, monogatari.element() returns <visual-novel> wrapped in the engine’s DOM helper, and monogatari.element(true) returns the element itself.

The order of the screens doesn’t matter. The engine finds each screen by its data-screen attribute, which every screen sets on itself from its tag (<settings-screen> gets data-screen="settings").

What goes inside it

Only the components that stay on the page for the whole game belong here: the screens, the menus, the text box and the dialog log.

Where Components
Directly inside <visual-novel> Language Selection Screen, Loading Screen, Main Screen, Game Screen, Gallery Screen, Credits Screen, Load Screen, Save Screen, Settings Screen, Help Screen
Inside <main-screen> Main Menu
Inside <game-screen> Dialog Log, Text Box, Quick Menu

WARNING

Keep every screen a button can open. If a screen's element is missing and the player presses its button (or your code calls monogatari.showScreen() for it), nothing opens: the current screen stays, and while the debug module is loaded a dialog says “The screen “…” is not in the page”. To drop a screen, remove its button too (see Main Menu and Quick Menu). Before 2.9.0, the engine closed the current screen anyway and left the player with an empty page.

Don’t add the elements that script actions create (<choice-container>, <text-input>, <message-modal>, <timer-display>, <centered-dialog>, <canvas-container>, <alert-modal>). Placed in the page by hand, they have nothing to show.

The engine removes one element by itself: <gallery-screen> is taken out of the page when your game declares no gallery images, so a starter game that hasn’t set up a gallery has no gallery screen at all.

Markup

<visual-novel> renders nothing of its own and keeps the children you wrote. Like every component, it gets data-component="visual-novel" and the class animated when the page loads:

<visual-novel class="animated" data-component="visual-novel">
  …the screens…
</visual-novel>

The engine adds these elements at the start of <visual-novel> while the game runs:

Element When
<alert-modal> When the engine asks the player something: quitting, overwriting or deleting a save, or rotating the device. See Alert Modal.
<div data-ui="broadcast" data-content="allow-playback"> A bar at the top (“Click here to allow audio playback”) when the browser refuses to play the main menu music until the player interacts with the page. A click on it plays the music and removes the bar.
<div data-ui="broadcast" data-content="new-content"> A bar (“There is new content available, reload the page to get the latest version”) when the service worker has installed a new version of a game served from a web host. A click on it removes the bar; the player reloads the page themselves.

The two broadcast bars are described from the engine’s code (src/engine/ui.ts and src/monogatari.ts); the browsers used for these docs played the music without asking.

Properties and attributes

None. The aspect-ratio behavior below comes from the ForceAspectRatio setting in js/options.js:

ForceAspectRatio What the engine does
'None' (the default) Nothing: the game fills the window.
'Visuals' Adds the class forceAspectRatio to the game screen’s [data-content="visuals"] element (the scene and the characters), and sizes it to the AspectRatio setting’s proportions ('16:9' in the starter game). The menus and the text box still use the whole window.
'Global' Adds forceAspectRatio to the element <visual-novel> sits in (#monogatari), so the whole game keeps the proportions. In a desktop build the window keeps them instead.

The engine sizes the constrained element again every time the window changes size. Configuration lists both settings.

Events

None of its own. The engine sends its events (didInit, didLocalize and the others) through <visual-novel>, which is why monogatari.on('didInit', …) listens on it. Events lists them.

Style it

<visual-novel> fills the element it sits in (width: 100%; height: 100%), and the engine’s stylesheet gives #monogatari position: relative. Anything inherited that you set on <visual-novel>, like a font, reaches every screen. In your game’s style/main.css:

visual-novel {
  font-family: Georgia, serif;
}

:root {
  --broadcast-background-color: #2b2233;
  --broadcast-text-color: #ffffff;
}

The bars’ colors come from two CSS variables, added in 2.9.0. For an older version, write the colors in a [data-ui="broadcast"] rule instead.

Hook What it is
visual-novel The root element.
.forceAspectRatio The element the ForceAspectRatio setting constrains.
[data-ui="broadcast"] The bars described above: white, full width, at the top of the game.

Replace or extend it

There’s nothing to replace: <visual-novel> has no markup or behavior beyond keeping its children. Change what’s inside it in index.html, and restyle it in style/main.css.