docs/astro/src/content/docs/reference/std-widgets/basic-widgets/checkbox.mdx
import CodeSnippetMD from '@slint/common-files/src/components/CodeSnippetMD.astro'; import SlintProperty from '@slint/common-files/src/components/SlintProperty.astro';
<CodeSnippetMD needsBackground imagePath="/src/assets/generated/std-widgets-checkbox-example.png" scale="3" imageWidth="100" imageHeight="50" imageAlt='checkbox example'> ```slint import { CheckBox } from "std-widgets.slint"; export component Example inherits Window { width: 200px; height: 25px; background: transparent; CheckBox { x: 5px; width: parent.width; height: parent.height; text: "Hello World"; } } ``` </CodeSnippetMD>Use a CheckBox to let the user select or deselect values, for example in a list with multiple options. Consider using a Switch element instead if the action resembles more something that's turned on or off.
The checkbox value changed
CheckBox {
text: "CheckBox";
toggled() => {
debug("CheckBox checked: ", self.checked);
}
}