Skip to content

SlideSwitch

Two-position slide switch (BOOL-005).

SlideSwitch, light theme SlideSwitch, dark theme

Controls, discrete · Widget catalog · API reference · schema slideswitch.schema.json

Example

The traits of the picture above:

ai.SlideSwitch(value=True, label="Slide")

Traits

Trait Type Default Set by Description
size array [90,44] host [width, height] in CSS pixels.
Common traits (13), shared with other widgets
Trait Type Default Set by Description
mode "control", "indicator" "control" host "control": the user sets the value; "indicator": display only.
label string "" host Plain text, never interpreted as HTML (SEC-002).
disabled boolean false host Greyed out, input rejected.
visible boolean true host
tooltip string "" host Plain text shown on hover.
style "modern", "classic", "system" "modern" host
theme "auto", "light", "dark", "system" "auto" host "auto": the style decides; "system": the host page or the operating system (STYLE-007).
skin object {} host Replaceable drawing parts: part name -> SVG source, sanitized (STYLE-005, STYLE-006).
value boolean false host, widget State of the control or indicator. Set by the host, or by the user in control mode.
default_state boolean false host State a latch returns to once the host has read it (BOOL-008).
mechanical_action "switch_when_pressed", "switch_when_released", "switch_until_released", "latch_when_pressed", "latch_when_released", "latch_until_released" "switch_when_pressed" host How the control reacts to the pointer (BOOL-007). With a latch, the host reads the value and restores default_state; without a host that does it, a latched value stays set.
latch_timeout number 0 host Seconds after which an unread latch expires (host side); 0: never.
confirm boolean false host Ask for a confirmation before changing the value (BOOL-011).

Set by: host, the program (Python, Julia, ...); widget, the user through the widget; derived, computed from other traits by the host that owns the state, or by the widget. See the trait contract.