Slint language preview
1. Slider component
a two-way binding between a handle and a property
horizon-dark
// a slider component
export component Slider {
in-out property <int> value: 0;
callback changed(int);
Rectangle {
background: #3a3a3a;
width: 200px;
height: 24px;
handle := Rectangle {
width: 12px;
x <=> root.value;
}
}
}
atom-one-dark
// a slider component
export component Slider {
in-out property <int> value: 0;
callback changed(int);
Rectangle {
background: #3a3a3a;
width: 200px;
height: 24px;
handle := Rectangle {
width: 12px;
x <=> root.value;
}
}
}
github-dark
// a slider component
export component Slider {
in-out property <int> value: 0;
callback changed(int);
Rectangle {
background: #3a3a3a;
width: 200px;
height: 24px;
handle := Rectangle {
width: 12px;
x <=> root.value;
}
}
}
dracula
// a slider component
export component Slider {
in-out property <int> value: 0;
callback changed(int);
Rectangle {
background: #3a3a3a;
width: 200px;
height: 24px;
handle := Rectangle {
width: 12px;
x <=> root.value;
}
}
}
nord
// a slider component
export component Slider {
in-out property <int> value: 0;
callback changed(int);
Rectangle {
background: #3a3a3a;
width: 200px;
height: 24px;
handle := Rectangle {
width: 12px;
x <=> root.value;
}
}
}
github
// a slider component
export component Slider {
in-out property <int> value: 0;
callback changed(int);
Rectangle {
background: #3a3a3a;
width: 200px;
height: 24px;
handle := Rectangle {
width: 12px;
x <=> root.value;
}
}
}
2. States and transitions
the states and transitions blocks
horizon-dark
component Toggle {
in-out property <bool> checked: false;
states [
active when checked: {
background: #4caf50;
}
inactive when !checked: {
background: #cccccc;
}
]
transitions [
in active: {
animate background { duration: 150ms; }
}
]
} atom-one-dark
component Toggle {
in-out property <bool> checked: false;
states [
active when checked: {
background: #4caf50;
}
inactive when !checked: {
background: #cccccc;
}
]
transitions [
in active: {
animate background { duration: 150ms; }
}
]
} github-dark
component Toggle {
in-out property <bool> checked: false;
states [
active when checked: {
background: #4caf50;
}
inactive when !checked: {
background: #cccccc;
}
]
transitions [
in active: {
animate background { duration: 150ms; }
}
]
} dracula
component Toggle {
in-out property <bool> checked: false;
states [
active when checked: {
background: #4caf50;
}
inactive when !checked: {
background: #cccccc;
}
]
transitions [
in active: {
animate background { duration: 150ms; }
}
]
} nord
component Toggle {
in-out property <bool> checked: false;
states [
active when checked: {
background: #4caf50;
}
inactive when !checked: {
background: #cccccc;
}
]
transitions [
in active: {
animate background { duration: 150ms; }
}
]
} github
component Toggle {
in-out property <bool> checked: false;
states [
active when checked: {
background: #4caf50;
}
inactive when !checked: {
background: #cccccc;
}
]
transitions [
in active: {
animate background { duration: 150ms; }
}
]
} 3. Imports and images
importing components and referencing image assets
horizon-dark
import { Button, VerticalBox } from "std-widgets.slint";
export component App inherits Window {
VerticalBox {
Image {
source: @image-url("logo.png");
}
Button {
text: @tr("Click me");
}
}
} atom-one-dark
import { Button, VerticalBox } from "std-widgets.slint";
export component App inherits Window {
VerticalBox {
Image {
source: @image-url("logo.png");
}
Button {
text: @tr("Click me");
}
}
} github-dark
import { Button, VerticalBox } from "std-widgets.slint";
export component App inherits Window {
VerticalBox {
Image {
source: @image-url("logo.png");
}
Button {
text: @tr("Click me");
}
}
} dracula
import { Button, VerticalBox } from "std-widgets.slint";
export component App inherits Window {
VerticalBox {
Image {
source: @image-url("logo.png");
}
Button {
text: @tr("Click me");
}
}
} nord
import { Button, VerticalBox } from "std-widgets.slint";
export component App inherits Window {
VerticalBox {
Image {
source: @image-url("logo.png");
}
Button {
text: @tr("Click me");
}
}
} github
import { Button, VerticalBox } from "std-widgets.slint";
export component App inherits Window {
VerticalBox {
Image {
source: @image-url("logo.png");
}
Button {
text: @tr("Click me");
}
}
}