CSS Variables
A CSS variable is a named value, such as --main-color, that many rules in a stylesheet read instead of repeating a color or a size. Monogatari’s stylesheet sets a default for each of its variables. When you set the same variable in style/main.css, every rule that reads it uses your value instead, on every screen at once.
Set a variable
Put a :root rule at the end of style/main.css, with one line per variable you want to change:
:root {
--main-color: rgba(92, 38, 28, 0.85);
--text-color: #4a2f25;
--screen-background-color: #f3e7d3;
--character-name-color: #f6c879;
}:root is the page itself, the same place the engine sets its defaults, and your file loads after the engine’s, so your values win. Variables you leave out keep their defaults. Save and reload: there’s nothing else to do.




A color can be any CSS color: a name (gold), a hex code (#f6c879) or rgba(red, green, blue, opacity), where an opacity under 1 lets the scene show through. The default --main-color is half transparent black, which is why the text box is see-through.
The engine’s variables
These are all the variables in the engine’s variables.css, with their defaults as written there. The engine’s compressed stylesheet stores some of them in a shorter form (#00000080 is rgba(0, 0, 0, 0.5)), so the developer tools may show them written differently.
| Variable | Default | What it changes |
|---|---|---|
--main-color |
rgba(0, 0, 0, 0.5) |
The background of the text box, of every button (main menu, choices, save and load screens, messages), of the round back button on the menu screens, of the save slots and their delete buttons, and of the quick menu bar on screens 601 pixels wide or wider. Also the border of the language buttons and the hover color of the quick menu while the game is in Hide mode. |
--text-color |
rgba(66, 66, 66, 0.9) |
The text of the page, so the titles and text of every menu screen, the dialog log (narrator lines included), the language buttons, and the keyboard keys drawn on the help screen (their background). Not the dialog: the text box has --text-box-text-color. |
--screen-background-color |
#f7f7f7 |
The page’s background, which shows behind the main menu and the other menu screens. Not the game screen: under the scene it’s black. |
--character-name-color |
#ffffff |
The name of a speaking character who has no color of their own. |
--quick-menu-text-color |
rgba(125, 125, 125, 0.5) |
On screens under 601 pixels wide, the quick menu’s icons at the top. At every width, the line under a quick menu button when the pointer is over it or it has the keyboard focus. From 601 pixels the icons and labels take --quick-menu-bar-text-color instead. |
--quick-menu-height |
2.5rem |
The height of the quick menu. From 601 pixels wide the text box sits this far above the bottom of the screen so the quick menu bar doesn’t cover it, and an NVL text box is this much shorter than the screen. |
--cursor-blinker |
'|' |
The character drawn as the typing cursor (in quotes, like any CSS text). |
--cursor-speed |
0.53s |
How long one blink of the cursor takes. |
--cursor-easing |
cubic-bezier(1, 0, 0, 1) |
The timing of the blink. The default switches it on and off sharply instead of fading. |
--character-move-speed |
0.2s |
How long a sprite takes to slide to its new place when the statement that moves it has with move. See Animations. |
--character-move-easing |
ease |
The timing curve of that slide: linear, ease-in, ease-out or any CSS timing function. |
--text-box-text-color |
rgb(255, 255, 255) |
The dialog in the text box. |
--button-text-color |
#f7f7f7 |
The text of every button that has no color of its own (the main menu, the save and load screens, messages, alerts), and the arrow of the round back button on the menu screens. |
--choice-text-color |
rgb(255, 255, 255) |
The text of choice buttons. |
--focus-border-color |
#222 |
The 4px frame around a button that has the keyboard focus. |
--link-color |
#00bcd4 |
Links in messages and in error dialogs. |
--modal-background-color |
#fff |
The box of messages, alerts, the name prompt, the dialog log and error dialogs. |
--modal-backdrop-color |
rgba(0, 0, 0, 0.5) |
The dimmed layer behind those boxes. |
--game-screen-background-color |
#000000 |
The game screen behind the scene, which shows where the scene picture doesn’t cover it. |
--quick-menu-bar-text-color |
#f7f7f7 |
From 601 pixels wide, the icons and labels of the quick menu bar. |
--quick-menu-bar-hover-text-color |
rgba(255, 255, 255, 0.8) |
From 601 pixels wide, a quick menu button’s icon and label when the pointer is over it or it has the keyboard focus. |
--save-slot-text-color |
#fff |
The name and date on save slots. |
--slider-track-color |
rgba(0, 0, 0, 0.5) |
The track of the sliders on the settings screen. |
--loading-bar-color |
#f16272 |
The filled part of the loading screen’s bar. |
--broadcast-background-color |
#fff |
The bars at the top of the game that ask to allow audio or say new content is available. |
--broadcast-text-color |
#424242 |
The text of those bars. |
The variables from --text-box-text-color down were added in 2.9.0. In older versions those colors are written into the engine’s rules, so the variables do nothing there.
character-name-color
The engine writes the name’s color onto the name element itself each time a character speaks: the character’s color if it has one, var(--character-name-color) if not. That’s why this variable is the only way to change the default name color from CSS: a color in a [data-ui="who"] rule never shows (see Your Game’s Stylesheet).
The typing cursor
The three --cursor- variables style a cursor that the engine doesn’t show by default. To turn it on, set TypingCursor in js/options.js:
'TypingCursor': true,The cursor then follows the text as it types and stays after the last letter, on lines in the text box, on NVL pages and on centered lines. It uses one more variable, --cursor-color, which is the text’s color (white in the text box) until you set it:
:root {
--cursor-blinker: '▌';
--cursor-color: #f6c879;
--cursor-speed: 0.8s;
}The Type Writer page shows how to turn it on for the text box only.
Variables for text effects
A line of dialog can wrap words in text effects such as {wave}…{/wave} or {glitch}…{/glitch} (the Type Writer page lists them all). A few of these effects read variables:
| Variable | Default | What it changes |
|---|---|---|
--effect-wave-amplitude |
0.3em |
How far the letters of wave, wave-slow, wave-fast and happy rise. A negative value makes them dip instead. Before 2.9.0 the default made them dip. |
--effect-wave-speed |
0.8s |
How long one wave takes, for wave only. wave-slow (1.5s) and wave-fast (0.4s) have fixed times. |
--effect-glitch-color-1 |
#ff0040 |
The first of the two colored shadows of glitch, glitch-hard and glitch-slow. |
--effect-glitch-color-2 |
#00ffff |
The second one. |
--effect-reveal-duration |
0.4s |
How long the effects that play as each letter appears take: fade and slide-up take three quarters of it, blur and flicker all of it, fade-slow twice as long, and so on for scale, scale-bounce, slide-down, impact, redacted, invisible-ink, handwriting and strike. Doubling it makes all of them twice as slow. |
The engine sets these on each letter (type-character[data-component]), not on :root, so a :root rule doesn’t reach them. Use the same selector in style/main.css:
type-character[data-component] {
--effect-wave-amplitude: 0.6em;
--effect-glitch-color-1: #d4a72c;
}The engine also writes --char-index on every typed letter: 0 for the first letter of the line, 1 for the next, and so on. The wave effects use it to start each letter a little later than the one before. You can read it in your own rules, for example animation-delay: calc(var(--char-index) * 0.05s);.
Variables for animations
The animation library behind with fadeIn and the other animation names reads three variables of its own:
| Variable | Default | What it changes |
|---|---|---|
--animate-duration |
1s |
How long an animation takes. slow, slower, fast and faster are multiples of it. The shakes keep their own lengths unless one of those four is added. |
--animate-delay |
1s |
The wait before an animation starts when the statement uses delay-1s to delay-5s (multiples of it). |
--animate-repeat |
1 |
How many times an animation plays with repeat-1; repeat-2 and repeat-3 play it twice and three times as often. |
Set them on :root like the engine’s own variables. Animations shows them in use.
Colors the variables don’t change
A few colors are still written straight into the engine’s rules. To change them, write a rule with the same selector in style/main.css:
| What | Color | Selector to use |
|---|---|---|
| Text fields | #f5f5f5 background; #eee in the name prompt, white with a #666 border on the save screen |
input, [data-component="text-input"] input, [data-component="save-screen"] input |
| The keys drawn on the help screen | white text | [data-component="help-screen"] [data-content="shortcut"] |
Monogatari 2 has no dark mode. For a dark look, set the variables to dark colors, --modal-background-color and --text-color included, and restyle the light text fields in this table as well, or their text becomes hard to read.
Related pages
- Your Game’s Stylesheet: where these rules go and how to check them.
- CSS Classes and HTML Data Attributes: select single elements when a variable is too broad.
- Components: which variables each component reads.