Skip to content

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.

ValuesAttributeMeaning
auto, light, darkdata-evo-prefWhat the visitor chose, or the default mode if they have not chosen.
light, darkdata-evo-modeWhat 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

ItemValue
Keyevo-mode
FormatTwo parts separated by a vertical bar: the mode (light, dark or auto) and the Unix timestamp of the choice, in seconds. Example: dark|1760000000.
WherelocalStorage with “Yes, in the browser and with an expiry”; sessionStorage with “Only for the session”; none with “No”.
ExpiryThe configured months (12 by default, 1 to 24), counted at 2,629,800 seconds per month.
When it is writtenOnly 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-mode key left in localStorage.
  • 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:

TriggerNotes
The plugin’s automatic buttonAccording to Button position.
The builder’s Colour mode elementA <button> with data-evoytmode-toggle.
Any element with data-evo-mode-toggleThe 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 propertyValues
prefauto, light, dark
modelight, 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 in aria-pressed (true when the page is shown dark) and a title giving the state and the next change.
  • Each change is announced through a role="status" region with aria-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) and prefers-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 customizer parameter 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.

VariableColour
--evoytmode-bgBackground
--evoytmode-surfaceSurfaces
--evoytmode-textText
--evoytmode-emphasisHeadings
--evoytmode-mutedMuted text
--evoytmode-borderBorders
--evoytmode-accentAccent
--evoytmode-on-accentText on the accent (white or black, chosen by contrast)

Builder element: Colour mode

evoAddons group.

OptionValues
StyleButton, Link, Icon only. Button and link follow your YOOtheme button styles.
Show the name of the mode next to the iconYes or no.
Accessible nameFree text. Empty uses the one from the plugin settings or the site language.
GeneralText alignment, top and bottom margins, block alignment and visibility.

evoMCP tools

The plugin announces them itself when evoMCP is installed.

PermissionToolWhat it does
Readevoytmode_get_settingsReturns every setting.
Writeevoytmode_set_settingsChanges settings. Supports dry_run and requires human approval.
Readevoytmode_statusPlugin 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:

ParameterType and values
default_modeauto, light, dark
baselight, dark
cyclethree, two
positionheader, floating-bottom-right, floating-bottom-left, floating-top-right, floating-top-left, none
iconsoutline, filled
rememberlocal, session, none
remember_monthsInteger from 1 to 24
show_label, skinBoolean
label_textText of up to 60 characters
skin_bg, skin_surface, skin_text, skin_emphasis, skin_muted, skin_border, skin_accentEmpty 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.