Skip to content

Switch

import { Switch } from "std-widgets.slint";
export component Example inherits Window {
width: 200px;
height: 40px;
Switch {
text: "Hello World";
}
}
slint
std-widgets switch example

A Switch is a representation of a physical switch that allows users to turn things on or off. Consider using a CheckBox instead if you want the user to select or deselect values, for example in a list with multiple options.

Properties

checked

bool (in-out) default: false

Whether the switch is checked or not.

Switch {
text: self.checked ? "Checked" : "Not checked";
checked: true;
}
slint

enabled

bool default: false

When false, the switch can’t be pressed

has-focus

bool (out) default: false

Set to true when the switch has keyboard focus

text

string default: ""

The text written next to the switch.

Switch {
text: "Switch with text";
}
slint

Callbacks

toggled()

The switch value changed

Switch {
text: "Switch";
toggled() => {
debug("CheckBox checked: ", self.checked);
}
}
slint

© 2024 SixtyFPS GmbH