Settings and Customise

Site & Content › Customise renders the form from the manifest and saves overrides; in the tutorial, the sample-parts Tagline reaches open pages without a reload.

A theme declares settings in its manifest. Operators edit them in Site & Content › Customise in the admin panel, which WordPress calls the Customizer. An operator’s saved values are overrides: they are stored per theme and setting, and they survive theme updates. The theme reads them at runtime through useThemeSettings().

Declaring settings

settings in theme.json is a list of groups; each group has an id, a label, an optional description and its fields. From sample-parts:

"settings": [
  {
    "id": "header",
    "label": "Header",
    "fields": [{ "id": "tagline", "type": "text", "label": "Tagline", "default": "Cards on the table" }]
  }
]

Every field has:

KeyMeaning
idcamelCase, unique within the theme; the key useThemeSettings() returns it under
typeOne of the types below
labelWhat the operator sees
descriptionOptional help text
defaultThe value used while the operator has saved none
visibleIfOptional: { field, equals }, { field, notEquals } or { field, truthy }; the field shows only while the condition on another field holds
TypeExtra keysAdmin control
text, textareamaxLength, mergeTagsText input, text area
numbermin, max, stepNumber input
rangemin, max (required), step, unitSlider
toggle—Switch
selectoptions: [{ value, label }]Select
color—Colour picker; #rrggbb or #rrggbbaa
imagerequireAltImage path

Section schemas use the same field vocabulary; see Sections and Sidebars.

Reading settings

import { useThemeSettings } from '@pe/sdk';

const settings = useThemeSettings();
const tagline = typeof settings.tagline === 'string' ? settings.tagline : '';

useThemeSettings() returns a flat object of field id to value (string | number | boolean | null): the operator’s override where one is saved, otherwise the active theme’s own default. A child theme’s settings come from its own manifest; its parent’s declared settings are not merged in. Check the type of each value you read, as sample-parts does; a part should render sensibly whatever it gets.

Under theme dev the proxy serves no settings, so every value is missing and the theme must fall back to its own defaults in code.

Settings in CSS

The host also writes the active theme’s short settings on <html> as data-th-setting-<field>, with the field id in kebab case: a toggle as true or false, a number as its digits, and a select or a short text made only of letters, digits, - and _ as itself (fourColorDeck: false becomes data-th-setting-four-color-deck="false"). Longer text, images and lists are left out. A setting that is pure CSS can then reach every page, including pages where no theme markup renders, such as the standard table:

:root[data-theme='my-theme'][data-th-setting-felt='ocean'] {
  --tbl-felt: #21639e;
}

The attributes follow live setting changes and disappear when the theme stops being active. theme dev writes none, so keep a fallback (for example an attribute on a part’s root, matched with :root:has(...)).

Overrides

  • An override is keyed by theme slug and setting id. Changing the active theme does not delete the overrides saved for another theme, and switching back finds them.
  • Save on Customise stores the values that differ from the defaults; Reset to defaults clears them.
  • Saved settings reach open pages live: every connected browser receives appearance_updated, fetches GET /api/v1/config/theme again and re-renders with the new values, without a reload.
  • Updating the theme and rolling back keep the overrides.

Token values and the custom CSS, which Customise also shows, reach open pages live too: the runtime re-reads the token sheet on appearance_updated.

Settings a theme does not own

These are operator settings, not theme settings, and live in Appearance rather than in the theme:

  • The active theme and whether players see it (Show the active theme to players).
  • The default colour scheme and whether players may choose a theme, and from which themes (the Player theme choice panel on Site & Content › Themes; see Appearance).
  • Branding: logo, dark logo, favicon and social-sharing image. The site name is the SEO site title in Settings. While Show the active theme to players is on, useBrand() returns the images as logoUrl, logoDarkUrl, faviconUrl and ogImageUrl (null for any not uploaded), and the favicon replaces the page’s own icon in the browser. Like every Appearance change, a new upload reaches open pages without a reload. Branding in the HTML head itself (the icon and social image a crawler sees) is server-side work of the SEO phase.
  • Custom CSS.
  • Sidebar contents and menus.
  • The front page.

The merge-tag namespace theme.settings.* is reserved for a theme’s settings; see Strings and Merge Tags.

Preview

Customise saves straight to the theme’s overrides; there is no unsaved preview of a change. To see a theme without showing it to players, use Preview on Site & Content › Themes, which applies it to your own browser only for an hour.

Try the live demo Pricing

Have questions about Poker Engine? We reply fast.