evoYTMode reference
Attributes on the html tag
The start-up script, inlined in the head, sets them before the first paint. The button script then keeps them up to date.
| Values | Attribute | Meaning |
|---|---|---|
auto, light, dark | data-evo-pref | What the visitor chose, or the default mode if they have not chosen. |
light, dark | data-evo-mode | What is shown. In auto it is resolved from the system preference; if the system expresses none, from the Native look of the site setting. |
The plugin also always adds html[data-evo-mode="dark"]{color-scheme:dark} and its light counterpart, so that the browser’s form controls and scrollbars follow the mode.
Browser storage
| Item | Value |
|---|---|
| Key | evo-mode |
| Format | Two parts separated by a vertical bar: the mode (light, dark or auto) and the Unix timestamp of the choice, in seconds. Example: dark|1760000000. |
| Where | localStorage with “Yes, in the browser and with an expiry”; sessionStorage with “Only for the session”; none with “No”. |
| Expiry | The configured months (12 by default, 1 to 24), counted at 2,629,800 seconds per month. |
| When it is written | Only when the button or a trigger link is pressed. Never on page load or reload. |
Reading rules:
- A value in any other format, dated more than five minutes in the future or older than the expiry is discarded and deleted. That includes the pre-1.1.0 format, which has no date.
- With “Only for the session” or “No”, the start-up script also deletes any
evo-modekey left inlocalStorage. - With “No” nothing is read or written. The button changes the mode on that page and the next page goes back to the default mode.
- If the browser blocks storage, the button keeps working for that page.
- With local storage, a change of choice in another tab is applied in the open ones too.
Triggers
Any of these changes the mode on click:
| Trigger | Notes |
|---|---|
| The plugin’s automatic button | According to Button position. |
| The builder’s Colour mode element | A <button> with data-evoytmode-toggle. |
Any element with data-evo-mode-toggle | The script cancels the click’s default action. |
A link <a href="#evo-mode"> | Same. |
State cycle with “Three”: automatic, light, dark and back to automatic. With “Two”: it toggles between light and dark according to the mode currently shown.
The evoytmode:change event
It is dispatched on document every time a mode is applied: on page load, when a trigger is pressed, when the system preference changes while on automatic, and when the choice changes in another tab.
detail property | Values |
|---|---|
pref | auto, light, dark |
mode | light, dark |
document.addEventListener('evoytmode:change', function (event) {
console.log(event.detail.pref, event.detail.mode);
});
The button
- It is a
<button type="button">with an accessible name (aria-label), its state inaria-pressed(truewhen the page is shown dark) and atitlegiving the state and the next change. - Each change is announced through a
role="status"region witharia-live="polite". - Minimum area of 44 × 44 px and a visible outline with
:focus-visible. - It respects
prefers-reduced-motion(no transitions if the visitor asked for less motion) andprefers-contrast: more(stronger border). - The icons are decorative (
aria-hidden). - There can be several buttons on a page; they all show the same state.
- Inside the YOOtheme Customizer (the
customizerparameter in the URL) the plugin adds nothing. - It only acts on the public site (frontend) and on HTML pages.
- It only acts when the page’s active template is YOOtheme or a child theme of it. With evoTheme or any other template it adds neither the button, nor the scripts, nor the skin.
Generic skin variables
With the skin on, they are defined on html[data-evo-mode="…"] for the mode opposite to the native look of the site.
| Variable | Colour |
|---|---|
--evoytmode-bg | Background |
--evoytmode-surface | Surfaces |
--evoytmode-text | Text |
--evoytmode-emphasis | Headings |
--evoytmode-muted | Muted text |
--evoytmode-border | Borders |
--evoytmode-accent | Accent |
--evoytmode-on-accent | Text on the accent (white or black, chosen by contrast) |
Builder element: Colour mode
evoAddons group.
| Option | Values |
|---|---|
| Style | Button, Link, Icon only. Button and link follow your YOOtheme button styles. |
| Show the name of the mode next to the icon | Yes or no. |
| Accessible name | Free text. Empty uses the one from the plugin settings or the site language. |
| General | Text alignment, top and bottom margins, block alignment and visibility. |
evoMCP tools
The plugin announces them itself when evoMCP is installed.
| Permission | Tool | What it does |
|---|---|---|
| Read | evoytmode_get_settings | Returns every setting. |
| Write | evoytmode_set_settings | Changes settings. Supports dry_run and requires human approval. |
| Read | evoytmode_status | Plugin enabled, YOOtheme version, element and assets complete on disk, skin on, position and default mode. |
core.manage on plugins is required, and core.edit to change settings. Parameters of evoytmode_set_settings:
| Parameter | Type and values |
|---|---|
default_mode | auto, light, dark |
base | light, dark |
cycle | three, two |
position | header, floating-bottom-right, floating-bottom-left, floating-top-right, floating-top-left, none |
icons | outline, filled |
remember | local, session, none |
remember_months | Integer from 1 to 24 |
show_label, skin | Boolean |
label_text | Text of up to 60 characters |
skin_bg, skin_surface, skin_text, skin_emphasis, skin_muted, skin_border, skin_accent | Empty or three or six digit hexadecimal |
A value outside what is allowed returns an error and changes nothing. With dry_run the tool returns the current and resulting state without saving.