Each section below is short and ends with a pointer to the page that holds the exhaustive list. The pointers matter: the lists of tokens, nodes and contracts are generated from the code, so they are always right, and this page never repeats them.
Tokens
A token is a CSS custom property named --pv-<name>, set in tokens.css. The game's own stylesheets read tokens and nothing else, so tokens are how a theme restyles the whole interface without markup or script.
- Typed. Every token has a type (a colour, a length, a font stack, a duration, a clip shape, a list of gradient layers, a choice among words…), and often a range. A value that does not fit is refused with the line, the token and the reason.
- Closed. A name outside the contract is refused. The contract is
crates/themes/tokens.json; the token reference is generated from it. - Partial is fine. A token you leave out keeps the game's neutral value. The component tokens (
--pv-card-*,--pv-button-*,--pv-input-*,--pv-tab-*,--pv-tooltip-*,--pv-list-row-*) default to references to the base tokens (--pv-card-bgis--pv-surface-2, which is--pv-plate-raised), so setting the base palette already restyles the components. - Layout words. A token of type choice takes one word from a closed list. The page turns each valid choice into a
data-layout-<name>attribute on<html>and the game's stylesheets react to it:--pv-layout-list: leftputs the list on the left,--pv-layout-tabs: railmakes the tabs a rail. The first word of each list is the current layout: a theme that says nothing changes nothing. - Narrow windows. Up to two
@media (max-width: <n>px)blocks, each holding one:root, override tokens for narrow windows (nfrom 320 to 4000). Image tokens stay in the main block. - Two guard rails. The map's picture must stay visible (at least 20 % of its light reaches the screen:
crates/themes/src/artwork.rs). The three curves of the replay graph must stay distinguishable (their hues differ by at least 30°:crates/themes/src/curves.rs). A theme that breaks one is refused whole, with the names of the tokens at fault. - A shared backdrop. On every page except the song selection (Download, Multiplayer, Profile, Clan, Skins, Mods, Help, a score's analysis), the map's picture sits behind a veil so a bright cover never reaches the page's titles and tabs.
--pv-page-scrimis that veil (by default the page background at 78 %; the guard rail above caps it at 90 %, so the picture stays visible) and--pv-page-art-blurblurs the picture behind it (0 keeps it sharp). A theme tunes both intokens.css. The song selection is not affected: it keeps--pv-shadealone.
A light theme sets --pv-color-scheme: light and redefines the tokens that default to dark-surface colours (the offset, tier and rating tokens: see the token reference).
Reference: tokens. Practice: quick start.
theme.css
theme.css styles the classes your template creates. It is a validated subset of CSS: Rust parses it, refuses anything outside the subset, and rewrites it before the page sees it. Every class .name becomes .tpl-<id>-name and every selector is placed under [data-direction="<id>"], so a theme cannot touch the rest of the game or another theme. It reaches the game's own elements through their data-* marks, never through their classes.
Reference and rules: theme.css and the generated CSS allow-list.
Templates
A template redraws the structure of a screen. theme.ts calls defineTheme({ screens, components }); each entry is a function that receives a typed context c and returns a node. The script runs once, when the theme loads, in a throwaway engine with no game API, and returns a tree of nodes from a closed list (box, row, text, slot, when, each…). Nothing of the script survives its run: only the tree, which Rust validates against the contract before the page draws a node of it. The page draws every tree with one generic renderer.
So a template cannot compute at draw time. It declares what to show (bind), when (when), repeated how (each) and what a control asks for (on.press). The game does the rest.
Full guide: templates. Every node and attribute: nodes.
Screens, places and slots
A screen is a whole page of the game that a theme may template. The templatable screens are: screen.library (map selection), screen.settings (the Settings window), screen.download (the Download page, with the download.card face for its results), screen.help, screen.result (the summary shown for ten seconds after a play), screen.lobby (the multiplayer room, with the player.card face for each player), screen.chat (the chat sheet), screen.profile, screen.clan, screen.replay (score analysis), screen.mods and screen.skins (with the catalog.card face). The contracts reference is generated from the game and always holds the current list. Their places, inputs and outputs are in the contracts reference. The rest of this section uses the map selection as the example. Its template (screens: { library: … }, for the contract named screen.library) composes it from places (also called slots). A place is a named position that the game fills with one of its own components: in the map selection screen they include list, search, header, tabs, panels and footer. The host builds the input of every place and mounts it where the template says c.slot('footer').
The template decides where each place stands and how it is wrapped: wrappers, order, extra decoration, extra facts around it. It does not decide what the place contains. A place marked required must appear at least once (inside a when it counts); that is how Play and the list cannot be removed, only moved.
The screens and their places are in the contracts reference. Practice: first layout.
Components and contracts
Every templatable piece of the game has a contract: the written agreement between the game and a theme. A contract states:
- the input: the facts a renderer receives, one state at a time (for example
play.labelfor the Play footer); - the outputs: what a renderer may ask for, each one an action of the game, with typed arguments (
confirmstarts the map); - the places (
slots) the contract leaves free for a template to fill; - the parts (
data-part) of the default render, which a node may carry and a stylesheet may target; - the host classes and CSS variables the game's stylesheet gives that a template may use;
- the musts: what every render of the contract must keep (for example that Play is a button, reachable and focusable). The game's own tests (
apps/web/tests/contracts.spec.ts) check the default render against them. At load the validator enforces the part a template can break: required places and required outputs.
A screen has the same shape (input, outputs, places, host classes, variables) plus the list of components a template may mount inside it. A component template (components: { 'library.footer': … }) replaces only that piece. A theme can write the screen, any components, or both.
The validator checks a template against its contract before the theme is used: every path exists in the input, every operator fits the type of the field, every output exists with its arguments, every class is the theme's own or one the contract lists, every part exists, every required place is placed and every required output is bound to a control. A template that fails is refused alone, with a message that says where.
Reference: contracts. Messages: reading errors.
Faces
A list row cannot be replaced like a footer: it is virtualised (hundreds of rows recycled while you scroll), and it has a context menu, a hover popover, Ctrl+click, keyboard focus and buttons beside it. So some contracts are faces (face: true in the contracts table): the set card of the song list, the difficulty row, the score card of the leaderboard and the result card of the Download page (download.card), the player card of the lobby and the chat (player.card) and the catalogue card (catalog.card) are faces, and the contracts reference marks every one.
For a face, the split is strict:
| The game keeps | The theme draws |
|---|---|
The root of the card (the button or plate, its edge, accessible name, aria-expanded, data-active), the keyboard (Enter, Space, Menu, Shift+F10), the context menu, the popovers, the virtualised row that carries it, the buttons beside a score and their tooltips. |
The inside of the root: layout, text, icons, pictures, gauges, repeated lists (box, row, column, text, icon, image, meter, each, when), classes, vars and part. |
What the validator refuses in a face: a button, toggle or dropdown (a face adds no tab stop and no action), a slot that mounts another contract, and any call to an output. The message reads a button is not allowed in library.setCard: the host draws and owns the card's own button, keyboard, menus and actions….
A face still places the game's own small widgets where it wants (for example the goal mark or the tier counts) with c.slot('goal'), c.slot('tiers'). The exact list is on each contract in the contracts reference. A face that leaves out a part such as artist only loses the gesture that part carries (Ctrl+click filters by it).
A face reads the host's variables with var() in theme.css (--set-color, --edge, --difficulty-color) and the row distance --row-distance: the number of rows between a row and the centre of the list. A theme can shape a carousel with it. Cookbook: slanted cards.
Inputs, outputs and bindings
- Input. The data a template can read. It is a tree of typed fields.
c.bind('map.bpm')reads one field as text, a number or a boolean. A path that does not exist is a type error in your editor and an error from Rust at load. At run time, a path that has nothing behind it shows nothing and makes a condition false; it never throws. - Outputs. The actions a control may call.
c.on.press('confirm')makes abuttoncall the outputconfirmwith its arguments in order and with the right types; a toggle or dropdown appends its new value as the last argument. A node may call only outputs of its own screen or contract. A theme can never invent an action. - Bindings. A binding links a node to a path:
text(c.bind('play.label')). A list of values is written one after the other.$alias.fieldreads the current item inside aneach;[]is allowed only in thefromof aslot. - Conditions.
c.field('path')compared with.eq,.gt… or tested with.truthy(); combined with.and,.or,.not. A condition decideswhen,classWhen,hidden,inert,disabled,pressed.
Guide: templates.
Formatting
The game shows numbers a certain way, and a theme should not reinvent it. c.fmt formats a numeric path as the game does:
| Call | Result |
|---|---|
c.fmt.rate(path, digits?) |
A playback rate, 1.25 (no x). |
c.fmt.count(path, digits?) |
A compact count, floored: 12k. |
c.fmt.percent(path, digits?) |
A number that is already a percentage (97.4 gives 97.40%); 2 digits by default. |
c.fmt.duration(path, digits?) |
A duration in seconds as m:ss or h:mm:ss. |
c.fmt.fixed(path, digits?) |
A fixed number of decimals (2 by default). |
A bare c.bind of a number shows it with at most two decimals, trailing zeros dropped (27.361499 reads 27.36, 3 reads 3). A path that is not a number formats to empty text. c.t('key', { name: value }) is the game's translated text for a key.
Live bars
Each bar of map.equalizer has two heights from 4 to 100: level, the note density of the map, and live, the same bar as the menu music plays it now (the game's spectrum folded into the same bars). map.listening is true while the music drives the bars.
- Opt in by binding. A template that binds
live(orlistening) makes the screen ask the game for the spectrum, only while a map is shown and the player has not asked for less animation. A theme that does not bind it costs nothing: no request, no analysis, no message. - Smoothing is the page's. A bar rises fast (attack about 45 ms) and falls slowly (release about 190 ms). Take each frame as it comes: no
transitionon the bars (measured: it makes every bar recompute its style on each frame for nothing visible). Set the height withtransform: scaleY(calc(var(--tpl-live) / 100)), notheight: a bar moves about thirty times a second and must not trigger layout. - Fallback. With no music (menu music off, loading, paused for the settings or during a play, or nothing received for a third of a second),
liveequalslevel, and the bars ease to the density in about half a second. With reduce motion on, the page never asks for the spectrum:liveisleveland the bars are still. - Cost. One update of the screen input per spectrum frame (about 30 a second, around 2.5 ms of script measured in the development browser), only while music plays. At rest nothing runs.
The recipe is in the cookbook; the fields are in the contracts reference.
The animation rule
No infinite animation on a screen at rest. An animation that loops forever (infinite) repaints its area on every frame even when nothing else moves. It was measured in the game's web view: fifteen equalizer bars and two infinite glows cost about three CPU cores on a menu left alone (about 6 % once the music is paused). So decorative motion plays once per selection.
- Hang the animation on
[data-entering], which the game sets for about 0.9 s after the selection settles (250 ms after the last change, and only when the new map is in another set). Putdata: { entering: c.bind('selection.entering') }on the node so that it carries the attribute. - Or hang it on
:hoveror:focus-visible, with a finiteanimation-iteration-count. - Put every moving animation in
@media (prefers-reduced-motion: no-preference). - Never start an entrance below 0.8 opacity. The selected map's heading, figures and panels already show the new map when their entrance plays, so they only settle: the game's shared keyframes
pv-slide-settleandpv-rise-settlerun fromopacity: .8, never from 0, and a theme's own entrance keyframes do the same. Starting from 0 makes the panel blink out and back every time the arrow keys move the selection. The validator does not check this; the game's spectests/selection-update-in-place.spec.tswalks every shipped theme and fails when a panel dips.
The validator does not forbid infinite (a theme that used it stays valid) but warns: "<id>": theme.css: warning: line N: an infinite animation repaints the page every frame, even on an idle screen; play it a few times (a finite animation-iteration-count), or once per selection under [data-entering]. The warning shows in the list under the picker, in the game's log and in check_theme. Treat it as an error.
Reduced motion
When the player asks for less animation (prefers-reduced-motion: reduce), the game's own motion collapses whatever the theme says: the durations its components read (--pv-dur-*) drop to almost zero, and the travel of entrance animations (--pv-shift-base) and the stagger drop to zero. --pv-motion-intensity (0 to 1) scales that travel and stagger for a calm theme; the game multiplies it by 0 under reduced motion. The data-entering entrance never plays.
What the game cannot do is stop your animations: a rule in theme.css plays as written. So the theme stops itself: put every animation and every moving transition in @media (prefers-reduced-motion: no-preference). Live bars are still under reduced motion, as above.
Localisation
theme.json carries the name and the description of the theme in other languages under localized, keyed by language code (the game has en, fr, zh and ko). The picker shows the entry that matches the game's language and falls back to the manifest's name and description when a language or a field is missing. Provide at least the languages you can write.
Text inside a template is shown as written, in every language. For a word the game already translates, use c.t('key') with one of the game's translation keys (c.t('ui.selected_map')). The examples use only such keys and the game's own text.
Accent modes
The accent is the colour of buttons and highlights. The player's Accent colour setting offers Theme default, Map artwork (the hue of the selected map's picture) and Custom colour. accent in theme.json says whether the theme listens:
"preference"(default): the accent follows the player's choice; Theme default is your--pv-accent. The old word"artwork"means the same."fixed": the accent is always your--pv-accent. Use it when the palette needs one colour: phosphor green, a brand orange."map": the accent is the selected map's own (the dominant hue of its artwork, or its difficulty colour), whatever the player's accent setting says, except a Custom colour, which still wins. Your--pv-accentis what shows while no map is selected. Use it when the interface should follow the cover, as the Vinyl theme does.
--pv-accent-2 is a second accent for secondary marks. --pv-ink is the text drawn on an accent-coloured surface: check it against both your accent and a light custom colour if the theme is "preference".
_base inheritance and fallbacks
Inheritance
The game's own folder themes/_base/ holds the templates every theme inherits. It is not a theme. A theme that does not write the template of a screen or a component takes the one of _base, component by component. If _base has none either, the contract's default render (a Svelte component) draws. A theme with no theme.ts at all gets the game's default composition, restyled by its tokens.
_base styles its classes as .tpl-base-<name>, globally. You do not write them. The reading order of a template is: the theme's own, then _base's, then the default render.
When something fails
Failure is never silent, and it is contained to the smallest part that failed. From the largest to the smallest:
| What failed | What happens | Where you see it |
|---|---|---|
| The chosen theme is not in the list (deleted, refused) | The game wears the default theme (stage), else the first listed, else its built-in neutral tokens. |
Nothing is lost; check the list of problems. |
theme.json, tokens.css, theme.css, or an image named by a token or by preview is invalid |
The theme is removed from the list. The other themes are unaffected. | "<id>": <file>: <where>: <reason> in the list under the picker and in the log. |
theme.ts throws, times out or goes over a budget |
The theme loads without its templates: tokens, CSS and images stay, and it takes the templates of _base. |
"<id>": theme.ts: <message> |
| One template is refused by validation | That template alone is dropped; the others stand. _base's, or the default render, draws instead. |
"<id>": theme.ts: <contract> › <node chain>: <reason> |
| A valid template throws while it draws | It is set aside for the session until the themes are reloaded. The default draws at once and the player is told once per contract: The template of "…" in the interface "…" cannot be drawn; the default one is used. | A notice in the game. |
Rows two to four happen at load and are what check_theme reproduces. The last happens in the page; it should not happen with a validated template, and it is the safety net.
Practical rule: never delete a template to "fix" an error. Read the message; it names the file, the node and the reason. See reading errors.
Versioning
themeApi in theme.json names the version of the contract your theme was written for. A newer one than the game speaks is refused in one sentence; an older one loads as long as the game can read it; absent means 1. What may change without a new version, and what needs one, is on the overview.