pysepal.solara.theme.ThemeState#

class pysepal.solara.theme.ThemeState(*args, **kwargs)[source]#

Session-scoped theme preference and resolved dark/light state.

Initialize with an initial mode and optional explicit dark value.

Attributes

dark

A boolean (True, False) trait.

mode

An enum whose value must be in a given sequence.

Methods

__init__

Initialize with an initial mode and optional explicit dark value.

mode_to_widget_dark

Map theme mode to ThemeToggle.dark semantics.

set_dark

Update the effective dark/light value.

set_mode

Update theme preference and keep fixed modes aligned with dark.

widget_dark_to_mode

Map ThemeToggle.dark semantics back to theme mode.

Parameters:
  • mode (str)

  • dark (Optional[bool])

ThemeState.__init__(mode='auto', dark=None, **kwargs)[source]#

Initialize with an initial mode and optional explicit dark value.

Parameters:
  • mode (str)

  • dark (bool | None)

static ThemeState.mode_to_widget_dark(mode)[source]#

Map theme mode to ThemeToggle.dark semantics.

Parameters:

mode (str)

Return type:

bool | None

ThemeState.set_dark(dark)[source]#

Update the effective dark/light value.

Parameters:

dark (bool)

Return type:

None

ThemeState.set_mode(mode)[source]#

Update theme preference and keep fixed modes aligned with dark.

Parameters:

mode (str)

Return type:

None

static ThemeState.widget_dark_to_mode(value)[source]#

Map ThemeToggle.dark semantics back to theme mode.

Parameters:

value (bool | None)

Return type:

str