Switch

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: (inout bool): Whether the switch is checked or not (default: false).
  • enabled: (in bool): Defaults to true. When false, the switch can't be pressed (default: true).
  • has_focus: (out bool): Set to true when the switch has keyboard focue (default: false).
  • text (in string): The text written next to the switch.

Callbacks

  • toggled(/* checked */ bool): The switch value changed

Example

import { Switch } from "@coop/lib.slint";

export component Example inherits Window {
    width: 200px;
    height: 25px;
    Switch {
        width: parent.width;
        height: parent.height;
        text: "Hello World";
    }
}