On this page

← All documentation

Interface themes

What a theme is, what it can and cannot change, the files of a theme folder, where themes are found, and how the theme contract is versioned.

An interface theme is the look and the layout of the game's menus: Stage, Classic, Cabinet, Carousel and the others are themes. A theme is a plain folder, read from disk like a mod or a skin. Delete the folder and the theme is gone. The player picks one in Skins → Interface (the setting uiTheme, whose value is the theme's id).

This section is the reference for writing one. If you have never made a theme, start with the quick start: a first theme takes ten minutes.

What a theme is

A theme is data, never code that runs while the game draws. Scripts have no access to the DOM, the CSS or the JavaScript of the game's web view, and every value that enters the page is validated in Rust first. So a theme is made of:

  • a manifest (theme.json) that names it;
  • a token file (tokens.css): colours, fonts, shapes, durations and layout words, in a strict subset of CSS;
  • optionally a stylesheet (theme.css) for the theme's own classes, in a validated subset of CSS;
  • optionally a template script (theme.ts) that decides where the parts of a screen stand. It runs once, when the theme loads, and returns a tree of nodes from a closed list. That tree is data too, validated against the contract of the screen;
  • pictures.

The themes crate (crates/themes) validates the folder and the host publishes only what passed to the page. A theme cannot execute or load anything.

What a theme can change

Level What you write What it changes
Tokens tokens.css Every colour, font, size, shape of plates and buttons, duration, easing, and the layout words (--pv-layout-*: which side the list is on, where the tabs go, how rows look). The full list is the token reference.
Styles theme.css The look of the theme's own classes, and of the game's elements through their data-* marks. See theme.css.
Templates theme.ts The structure of a templated screen: which places stand where, how they are wrapped, what extra facts are shown, and the inside of list cards (faces). See templates.
Pictures images/… Backgrounds, overlays, the preview of the picker card.

Which screens and components can be templated is the content of the contracts reference. Every screen that is not listed there keeps its structure; it still follows the tokens.

What a theme cannot change

These limits are the point of the design: whatever the theme says, the game stays usable.

  • Nothing a screen needs can disappear. A template must place every required place of its screen and must bind every required output of a component to a control. Play can move, never vanish. See templates and concepts.
  • The keyboard and the accessibility tree stay the host's. Shortcuts, the focus order (the order of the tree), the roles and accessible names of the game's own controls, the virtualised list and the actions of each row do not depend on the template.
  • The map's picture stays visible. A theme may tint, darken, blur or recolour it, never remove or bury it. The validator (crates/themes/src/artwork.rs) refuses a token set that lets less than 20 % of the picture through. See tokens.
  • Icon buttons keep their geometry. Their size and shape come from tokens; case, letter spacing and padding do not reach them.
  • A theme runs no code while the game draws. theme.ts runs once, at load, under budgets (500 ms, 16 MiB, 128 KiB of source, 4 000 nodes). See templates.
  • Gameplay is not a theme. The playfield and the in-game HUD are the business of skins and mods.

The theme folder

The folder is named after the theme's id.

themes/<id>/
  theme.json     the manifest (required)
  tokens.css     the tokens (required unless theme.json names another file)
  theme.css      optional: styles of the theme's own classes
  theme.ts       optional: the templates, defineTheme({ … })
  preview.png    optional: the picture of the picker card (named by "preview")
  images/…       optional: pictures named by image tokens, templates and theme.css

Only these files are read. Anything else in the folder (a theme.d.ts for your editor, notes, source files) is ignored.

theme.json

The manifest is at most 64 KiB. name, description and author are trimmed and may not contain control characters.

Field Meaning
id Required. Must be the folder name: lowercase letters, digits and hyphens, starting with a letter or a digit, 32 characters at most. The id base is reserved for the default templates: a theme with that id cannot have theme.css or theme.ts.
name Required. 1 to 48 characters.
description 0 to 240 characters.
version Your own version label: letters, digits and . _ + -, 32 characters at most.
author 0 to 64 characters.
order Position in the picker, 0 to 1000 (100 when absent); ties are broken by id.
themeApi The version of the theme contract the theme was written for: a whole number from 1. Absent means 1. The game speaks 2. A theme that asks for a newer version than the game speaks is refused with a sentence that says what to do. Write 2 to template the screens, faces and "accent": "map" that version 2 added. See versions.
preview A picture of the folder shown on the picker card (png, jpg, jpeg, webp, gif or svg, 4 MiB at most). Without it the card is drawn from your tokens.
fonts Fonts the theme ships: { "Unbounded": "fonts/Unbounded.ttf" }, a family name (1 to 48 ASCII letters, digits, spaces, - and _, starting with a letter; not a CSS generic such as serif) and a .ttf, .otf, .woff or .woff2 file of the fonts/ folder. At most 8 fonts, 4 MiB each, 12 MiB in all; a file must start like the font it claims to be. The game declares the @font-face; use the names in the --pv-font-* tokens and in theme.css. Ship only fonts whose licence allows it (OFL fonts do).
sounds Interface sounds: { "select": "sounds/select.ogg" }, a moment (select: the selection settled on another map; confirm: Play or Enter; back: the menu drawer or Escape; open: another page; toggle: a gameplay modifier switched) and a .wav, .ogg, .mp3 or .flac file of the sounds/ folder that starts like a sound. 512 KiB each, 2 MiB in all; the first second plays. The game plays them on the player's device at the Interface sounds volume (Settings → Audio), never during a play.
options Options the player sets in Skins while the theme is worn, at most 12: { "id": "wave", "kind": "toggle", "label": "Font wave", "localized": { "fr": "Vague" }, "default": true }; kind is toggle (default true/false), choice (2 to 8 choices of { "id", "label", "localized" }, default one of their ids) or color (default #rgb or #rrggbb). <body> carries data-opt-<id> (a toggle that is on: present; a choice: its id) and --opt-<id> (a colour; a toggle: 1 or 0): [data-opt-wave] .title { animation: … }, color: var(--opt-glow, #3fd17a).
accent "preference" (default): the accent follows the player's Accent colour setting (Theme default, Map artwork or Custom colour; Theme default is your --pv-accent). "fixed": the accent is always your --pv-accent, whatever the player chose (a signature colour). "map" (needs "themeApi": 2; with 1 the theme loads and follows the player's setting, with a notice): the accent is the selected map's own (the dominant hue of its artwork, or its difficulty colour), as if the player had chosen Map artwork; a Custom colour still wins, and your --pv-accent is what shows while no map is selected. The old word "artwork" is accepted and means "preference".
tokens The name of the token file, a .css file of the folder. Default tokens.css.
localized The name and the description in other languages: { "fr": { "name": "…", "description": "…" } }. At most 16 languages; a code is 2 to 8 letters or hyphens. The game has en, fr, zh and ko. A language that is missing falls back to name and description.

A minimal manifest:

{
  "id": "first-theme",
  "name": "First theme",
  "description": "The smallest useful theme: a manifest and a palette in tokens.css, nothing else. Teal on deep blue, rounded plates.",
  "version": "1.0.0",
  "author": "Prism docs",
  "themeApi": 2,
  "accent": "fixed",
  "tokens": "tokens.css",
  "localized": {
    "fr": {
      "name": "Premier thème",
      "description": "Le plus petit thème utile : un manifeste et une palette dans tokens.css, rien d'autre. Turquoise sur bleu profond, plaques arrondies."
    }
  }
}

The other files

  • tokens.css holds one :root { --pv-x: value; } block and up to two @media (max-width: <n>px) blocks for narrow windows. Nothing else is allowed. 64 KiB, 200 declarations, 600 characters per value. A token you leave out keeps the game's neutral value, so a theme can be partial. See concepts and the token reference.
  • theme.css is limited to 256 KiB, 2048 rules and 40 declarations per rule. See theme.css.
  • theme.ts is limited to 128 KiB. See templates.
  • Pictures: png, jpg, jpeg, webp, gif or svg, 4 MiB each, up to 512 files under images/ (four levels deep). Templates and styles may name only these files.

The default templates every theme inherits live in the game's own folder themes/_base/. It is not a theme: a folder whose name starts with _ is never listed, and _base is read only from the game's own themes/ folder. See concepts.

Where themes are looked up

The game looks in two folders, in this order:

  1. themes/ next to prism.exe: the themes that ship with the game. In a development checkout this is the repository's content/themes/, found by walking up from the executable to the directory that holds Cargo.lock.
  2. <data>/themes: the player's own themes. PRISM_THEMES_DIR points the game at another folder instead. On Windows <data> is %LOCALAPPDATA%\Prism\PrismNG\data (the preview channel uses PrismNG-PBE). Open themes folder in Skins → Interface opens it.

If the same id is found twice, the first wins and the second is reported: you cannot replace a shipped theme by giving yours its id. At most 64 themes are loaded. After you change a folder, use Reload themes in the same place; the game lists the folders again and runs the scripts again. Sharing covers installing and troubleshooting.

The map of this section

Page Read it to
Quick start Make a first theme (tokens), then a first layout (theme.ts).
Concepts Understand tokens, templates, screens, slots, contracts, faces, live data, motion, fallbacks.
Templates Write theme.ts: the execution model, bindings, conditions, events, slots, faces.
theme.css Style your classes and reach the game's elements.
Cookbook Copy a recipe: banner, slanted cards, poster, terminal list, live bars, settings rail.
Reading errors Understand a message and fix it; the catalogue of errors.
Sharing Install, share, check before you publish, troubleshoot.
Tokens Generated: every --pv-* token with its type, range and role.
Nodes Generated: every constructor of theme.ts, with its attributes.
Contracts Generated: every screen and contract: input, outputs, places, parts, host classes, musts.
CSS allow-list Generated: selectors, at-rules and properties theme.css accepts.

For an AI assistant, see llms-themes.txt and Feed an AI assistant: one self-contained document for writing a theme. The types of theme.ts are in theme.d.ts.

Versions and stability

A theme is written against a contract: the paths of the input of every screen and component, the outputs, the places, the parts (data-part), the classes of the host, the node kinds and attributes, the properties of theme.css, the tokens. The contract has a version.

THEME_API and themeApi

The game speaks one version, the constant THEME_API (crates/themes/src/api.rs); check_theme prints it (theme API N). A theme names the version it was written for with "themeApi": N in theme.json. Absent, it is 1: every theme written before the field existed.

  • A theme that asks for a newer version than the game speaks is refused in one sentence, instead of failing later on a node or a property that this game does not know: theme.json: themeApi N is newer than this game speaks (theme API M): update the game, or use a version of the theme written for API M.
  • A value that is not a whole number from 1 ("1", 0, 1.5, true) is refused, and the message says what was found.
  • A theme that asks for an older version is loaded as long as the game can still read it.

Write the number of the version you tested your theme against. The repository tool check_theme prints the version your copy of the game speaks.

What changes in version 2

Theme API 2 only adds: no path, output, place, part, class, node kind, property or token of version 1 was removed or renamed, and no type changed. To move a theme to version 2, write "themeApi": 2 in its theme.json; nothing else has to change. The shipped themes declare 2.

What a theme that declares 1 (or nothing) keeps: everything it used. It loads, and its version 1 templates are validated and rendered as before.

What it is refused, one notice per template or field, the theme still loading:

  • the template of a screen or a face added in version 2: screen.chat, screen.clan, screen.download, screen.help, screen.lobby, screen.mods, screen.profile, screen.replay, screen.result, screen.settings, screen.skins, and the faces catalog.card, download.card, player.card and library.chartRow. The theme keeps its tokens, its CSS and its other templates; the page takes the template of _base, then the game's own render. The notice names what to do: requires themeApi 2: the screen "screen.settings" was added in theme API 2 and this theme declares themeApi 1; set "themeApi": 2 in theme.json once the theme is written for version 2 (see the error);
  • "accent": "map": the theme loads and its accent follows the player's setting, as "preference" does, with a notice that names it.

One contract changed shape: library.chartRow was a component that drew its own button and became a face in version 2 (the game keeps the button, the keyboard and the menus, the theme draws the inside). A version 1 template of it is refused until the theme declares 2; no shipped theme had one, and it must be rewritten as a face, without a button. Every contract and screen the contracts reference lists as added in theme API 2 needs "themeApi": 2.

What stays within a version

The game may do all of this without changing THEME_API. None of it breaks a theme.

  • Add: an input path, an output, an optional place, a part, a host class, a state, a contract or a screen, a node kind or an attribute of a node, a CSS property, a value, a pseudo-element, a filter function, an @media condition, a --pv-* token (with a neutral value: a theme that ignores it keeps its look).
  • Widen: a limit (size, node count, budgets) may go up, a token range may widen, an enumeration may gain a value. A theme that compares a field with the values it knows stays correct.
  • Change what a theme cannot see: the DOM inside a host render (outside its data-* marks, its parts and its listed classes), the default renders, the templates of _base, the wording of error messages (read them, do not parse them), performance, and validation that gets more precise about something that was already wrong.

What a new version means

These need a new version of the contract, published next to the old one for as long as the game can:

  • removing or renaming a path, an output, a place, a part, a host class, a token, a node kind, a property or a value;
  • changing the type of a path, or the order or the type of the arguments of an output;
  • making a place or an output required when it was not;
  • giving an existing name another meaning;
  • lowering a limit below what a shipped theme uses.

So an update of the game does not silently break your theme within a version. When a new version comes, your theme keeps asking for the version it was written for until you port it. The tests protect the promise: the embedded contracts (apps/web/packages/@pvng/ui-contracts/contracts.json) and the SDK (content/mods/sdk/theme.d.ts) are generated, and a test theme per version must keep passing crates/modding/tests/theme_fixtures.rs.

Source in the game repository: docs/themes.md,crates/themes/src/library.rs,crates/themes/src/api.rs,crates/skin/src/shipped.rs,apps/desktop/src/app/interface_themes.rs,apps/web/src/theme/themes.ts