Skip to content

TextField

import { TextField, Vertical } from "material.slint";
export component Example inherits Window {
width: 200px;
height: 100px;
Vertical {
TextField {
label: "Name";
placeholder: "Enter your name";
}
}
}
slint

A widget used to enter a single line of text with additional features like icons and supporting text.

bool default: true

When false, the text field is disabled and cannot be interacted with.

bool default: false

Indicates whether the text field should display an error state.

bool (out) default: false

Set to true when the text field currently has the focus.

string default: ""

The label text displayed above the text input.

image default: the empty image

An icon displayed at the beginning of the text input.

string default: ""

A placeholder text being shown when there is no text in the edit field.

string default: ""

Additional text displayed below the text input, often used for hints or error messages.

string (in-out) default: ""

The text being edited.

image default: the empty image

An icon displayed at the end of the text input.

Selects the text between two UTF-8 offsets.

Selects all text in the text field.

Clears the current text selection.

Copies the selected text to the clipboard and removes it from the text field.

Copies the selected text to the clipboard.

Pastes the text content of the clipboard at the cursor position.

Invoked when the enter key is pressed.

TextField {
accepted(text) => {
debug("Accepted: ", text);
}
}
slint

Emitted when the text has changed because the user modified it.

TextField {
edited(text) => {
debug("Text edited: ", text);
}
}
slint

Invoked when a key is pressed, the argument is a KeyEvent struct. Use this callback to handle keys before TextField does. Return accept to indicate that you’ve handled the event, or return reject to let TextField handle it.

Invoked when a key is released, the argument is a KeyEvent struct. Use this callback to handle keys before TextField does. Return accept to indicate that you’ve handled the event, or return reject to let TextField handle it.

Invoked when the leading icon is clicked.

TextField {
leading_icon_clicked() => {
debug("Leading icon clicked");
}
}
slint

Invoked when the trailing icon is clicked.

TextField {
trailing_icon_clicked() => {
debug("Trailing icon clicked");
}
}
slint

© 2025 SixtyFPS GmbH