Skip to content

Button

import { Button, VerticalBox } from "std-widgets.slint";
export component Example inherits Window {
width: 200px;
height: 100px;
VerticalBox {
label := Text {
text: "Button not clicked";
}
Button {
text: "Click Me";
clicked => {
label.text = " Button clicked";
}
}
}
}
slint

A simple button. Common types of buttons can also be created with StandardButton.

Properties

checkable

bool default: false

Shows whether the button can be checked or not. This enables the checked property to possibly become true.

Button {
text: "Checkable Button";
checkable: true;
}
slint

checked

bool (in-out) default: false

Shows whether the button is checked or not. Needs checkable to be true to work.

enabled

bool default: true

Defaults to true. When false, the button cannot be pressed.

has-focus

bool (out) default: false

Set to true when the button has keyboard focus

icon

image default: the empty image

The image to show in the button. Note that not all styles support drawing icons.

pressed

bool (out) default: false

Set to true when the button is pressed.

text

string default: ""

The text written in the button.

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

primary

bool default: false

If set to true the button is displayed with the primary accent color.

colorize-icon

bool default: false

If set to true, the icon will be colorized to the same color as the Button’s text color.

Callbacks

clicked()

Invoked when clicked: A finger or the left mouse button is pressed, then released on this element.

Button {
text: "Click me";
clicked() => {
debug("Button clicked");
}
}
slint

© 2024 SixtyFPS GmbH