On this page

← All documentation

theme.css allow-list

Every selector, at-rule, property, value form and variable that theme.css accepts, and its limits, read from the validator.

theme.css is a validated subset of CSS for the classes of a theme. This page lists exactly what the validator accepts; anything else is refused with the line and the reason. The lists are generated from the validator itself (themes::stylesheet::check, probed by the cargo example theme_reference), so they cannot drift from the game. How to use the subset, and what the rewriting does to your file, is in theme.css.

Limits

Limit Value
File size 256 KiB
Rules in a file (style rules and keyframe steps together) 2,048
Declarations in one rule 40
Words, numbers and symbols in one value 200
Nesting depth of functions in a value 5
Characters of a string (no \, no control character) 80
Steps of one @keyframes 24
Characters of a class name (lower-case letters, digits, -, starting with a letter) 40
Characters of a @keyframes name (same alphabet) 40
Characters of a data- name in a selector, after data- 24
Characters of the value in [data-name="value"] (letters, digits, -, _, .) 40
Characters of a --tpl- variable name, after --tpl- (lower-case letters, digits, -) 32
Conditions joined by and in one @media 2

Selectors

A selector is made of the theme's own classes and the game's data-* marks.

  • .name: a class of the theme. A selector starts with one of the theme's classes. Compound selectors chain them: .card.selected.
  • [data-name] and [data-name="value"] (the data- attributes of the game's elements and of your data attributes), after a class or further along a selector. Nothing else is an attribute selector.
  • Pseudo-classes: :hover, :focus-visible, :focus-within, :active, :disabled, :first-child, :last-child.
  • Functional pseudo-classes, holding simple selectors of classes and not nested: :not(), :is(), :where().
  • Pseudo-elements, once, last in a selector: ::before, ::after. They draw decoration with content.
  • Combinators: the descendant (a space) and the child >. Selectors are separated by commas.

Refused: element selectors (div), the universal selector *, id selectors #x, the combinators +, ~ and &, any other pseudo-class or pseudo-element, a pseudo-element in the middle of a selector, and any selector that does not start with one of the theme's classes.

At-rules

Only @keyframes and @media. Any other at-rule (@import, @font-face, @supports…) is refused.

  • @media holds style rules only (no at-rule inside, no nesting). Its conditions are written (feature: value), at most 2 joined by and. Features: max-width, min-width, max-height, min-height, prefers-reduced-motion. A size is a whole number of px from 1 to 10,000; prefers-reduced-motion is reduce or no-preference.
  • @keyframes <name> holds steps from, to or <n>% (0 to 100), at most 24. An animation named in animation or animation-name must be defined by a @keyframes of the same file.

Properties and values

A property outside these lists is refused with this property is not allowed in theme.css. A property takes values of the classes shown. Plain words (center, bold, row…) are accepted for every property that is not a closed list; the browser ignores a word it does not know. !important, backslashes in strings and url() outside images/ are refused everywhere.

Value classes

Class Accepts
length A number with a unit (px, em, rem, vw, vh, vmin, vmax, ch) or a bare 0; at most 10,000 in absolute value.
percentage <n>%, at most 10,000.
number A unitless number, at most 100,000. A bare 0 also stands for a length, a percentage, an angle or a time.
color #rgb, #rgba, #rrggbb, #rrggbbaa, and the colour functions listed below. Colour names (red, transparent) are plain words.
angle A number with deg, turn, rad, at most 3,600.
time A number with s or ms, at most 60,000.
fraction <n>fr, at most 1,000.
string A quoted string of at most 80 characters.
url url("images/<file>"): one quoted path of a picture that exists in the theme's images/ folder (png, jpg, jpeg, webp, gif, svg). Nothing else.
gradient A gradient function (listed below).
transform A transform function (listed below).
filter A filter function (listed below).
backdrop A backdrop-filter function (listed below).
shape A basic shape function (listed below).
easing An easing function (listed below), or a keyword.
grid A grid function (listed below).

Properties by value

Properties that accept the same classes are grouped. A name ending in * is a family: every property of that prefix (margin-* is margin-top, margin-inline-start…).

Value classes Properties
length letter-spacing, word-spacing
length · color box-shadow, text-shadow
length · number · color outline, outline-*
length · percentage background-*, bottom, column-gap, flex-basis, gap, height, inset, left, margin, margin-*, mask-position, mask-size, max-height, max-width, min-height, min-width, object-position, padding, padding-*, right, row-gap, top, transform-origin, width
length · percentage · number flex, font-*, line-height
length · percentage · number · color border, border-* (except border-image*), text-*
length · percentage · number · color · angle · url · gradient background
length · percentage · number · fraction · string · grid grid, grid-*
length · percentage · number · string font
percentage · number opacity
number aspect-ratio, flex-grow, flex-shrink, order
number · time · easing animation-*, transition, transition-*
color background-color, color
string content, font-family
url · gradient background-image, mask-image
transform transform
filter · backdrop filter
backdrop backdrop-filter
shape clip-path
words only align-*, flex-direction, flex-flow, flex-wrap, justify-*, overflow-wrap, place-*, white-space, word-break

Properties with a closed list of words

These properties take one of these words (and the CSS-wide inherit, initial, unset, revert) and nothing else.

Property Words
cursor auto default pointer text move not-allowed grab grabbing wait help crosshair progress zoom-in zoom-out none
display flex grid block none inline-flex inline-block inline inline-grid contents
mask-repeat repeat no-repeat repeat-x repeat-y round space
mix-blend-mode normal multiply screen overlay darken lighten color-dodge color-burn hard-light soft-light difference exclusion hue saturation color luminosity plus-lighter
object-fit fill contain cover none scale-down
overflow visible hidden auto scroll clip
overflow-x visible hidden auto scroll clip
overflow-y visible hidden auto scroll clip
pointer-events auto none
position static relative absolute sticky
visibility visible hidden collapse
writing-mode horizontal-tb vertical-rl vertical-lr sideways-rl sideways-lr

Special cases

  • z-index: a whole number from −50 to 50, or auto.
  • animation and animation-name: the names they use are the @keyframes of the file; the validator renames them with the theme's prefix.
  • content: none, normal or a short quoted string, for ::before and ::after. No attr(), no counters. The text it draws is decoration that screen readers may read: never put information in it.
  • border-image*: refused.

Functions

Functions are allowed only where the value class of the property takes them. var(--name) and var(--name, fallback) are allowed in every value.

For Functions
numbers, lengths, angles, times (calc and the like) calc() min() max() clamp() var()
colours rgb() rgba() hsl() hsla() hwb() color-mix()
gradients (background, background-image) linear-gradient() repeating-linear-gradient() radial-gradient() repeating-radial-gradient() conic-gradient() repeating-conic-gradient()
transform translate() translatex() translatey() translatez() translate3d() scale() scalex() scaley() scale3d() rotate() rotatex() rotatey() rotatez() skew() skewx() skewy()
filter blur() brightness() contrast() drop-shadow() grayscale() hue-rotate() saturate() sepia()
backdrop-filter blur() saturate()
clip-path polygon() inset()
easing (transition*, animation*) cubic-bezier() steps()
grid templates repeat() minmax() fit-content()
pictures url()

Variables

A rule may declare three kinds of custom property. Read any of them with var(--name).

  • --tpl-<name>: your own variables (at most 32 characters after the prefix). Their values may be of any value class. Set them from a template with the vars attribute.
  • The design tokens of kind case, clip, color, duration, easing, filter, font, length, opacity, ratio, shadow, weight, set for the subtree of the rule only (the type scale of a banner, the accent of a panel). The value follows the grammar of the token (tokens).
  • The plate variables --plate, --edge, --clip, --clip-edge: the fill and edge (colour or gradient) and the shapes (clip) of a .pv-plate of the game.

The tokens of the other kinds (scheme, layers, image, choice: the layout and graph words, pictures, gradient layers, the colour scheme) stay in tokens.css, and so does --pv-art-filter, which is judged on the whole screen. Setting one in theme.css is refused with this token is set in tokens.css, not in theme.css.

Notices

An animation that runs forever (infinite) is accepted with a notice, not refused: it repaints its region every frame even when nothing else moves, which costs the game's web view on a menu left alone.

What the game does to the file

Every class .name becomes .tpl-<id>-name, every selector is placed under [data-direction="<id>"] (a theme cannot touch the rest of the game), every @keyframes name and its uses get the same prefix, and every url() becomes the protocol URL of the picture.

Source in the game repository: content/dev-src/generated/theme-css.json,crates/themes/src/stylesheet.rs,crates/modding/examples/theme_reference.rs