Allows defining multiple named themes (light/dark/any) that can be switched at runtime via container.loadTheme(name).
{
"themes": [
{
"name": "dark",
"default": {
"value": true,
"mode": "dark"
},
"options": {
"background": { "color": "#0d1117" },
"particles": { "color": { "value": "#ffffff" } }
}
},
{
"name": "light",
"default": {
"value": true,
"mode": "light"
},
"options": {
"background": { "color": "#ffffff" },
"particles": { "color": { "value": "#000000" } }
}
}
]
}
nameA string identifier used to reference the theme in container.loadTheme("dark").
defaultControls whether and when this theme is applied automatically.
| Key | Type | Values | Notes |
|---|---|---|---|
default.value |
boolean |
true / false |
If true, this is the default theme for the given mode |
default.mode |
string |
"any" / "dark" / "light" |
Applies when the OS/browser reports this color scheme |
"dark" — applied when prefers-color-scheme: dark is detected"light" — applied when prefers-color-scheme: light is detected"any" — applied regardless of system preferenceIf more than one theme sets default.value: true for the same mode, the last one wins.
optionsA partial Options object. Only the properties you specify will override the base config — everything else remains unchanged.
const container = await tsParticles.load({
id: "tsparticles",
options: {
/* ... */
},
});
// Switch to a named theme
container.loadTheme("dark");
// Reset to the default theme for the current mode
container.loadTheme(undefined);
default.value: true for the same mode — only the last one is usedname that was not registered in themes to loadTheme() — nothing changesoptions and expecting deep merge — only specified keys are overridden