Skip to content

TextEdit

import { TextEdit, VerticalBox } from "std-widgets.slint";
export component Example inherits Window {
width: 200px;
height: 200px;
VerticalBox {
TextEdit {
font-size: 14px;
text: "Lorem ipsum dolor sit amet,\n consectetur adipisici elit";
}
}
}
slint
std-widgets textedit example

Similar to LineEdit, but can be used to enter several lines of text

length default: 0px

The size of the font of the input text.

string default: ""

The name of the font family selected for rendering the text.

bool default: false

The italic state of the font of the input text

string (in-out) default: ""

The text being edited

TextEdit {
text: "Initial text";
}
slint

bool (out)

Set to true when the widget currently has the focus.

bool default: true

When false, nothing can be entered.

bool default: false

When set to true, text editing via keyboard and mouse is disabled but selecting text is still enabled as well as editing text programmatically.

enum TextWrap default: the first enum value

The way the text wraps (default: word-wrap).

TextWrap

This enum describes the how the text wraps if it is too wide to fit in the width of a Text or StyledText element.

  • no-wrap: The text won’t wrap, but instead will overflow.
  • word-wrap: The text will be wrapped at word boundaries if possible, or at any location for very long words.
  • char-wrap: The text will be wrapped at any character. Currently only supported by the Qt and Software renderers.

enum TextHorizontalAlignment default: the first enum value

The horizontal alignment of the text.

TextHorizontalAlignment

This enum describes the different types of alignment of text along the horizontal axis of a Text or StyledText element.

  • start: The text will be aligned with the start edge of the containing box. This could be left or right depending on the direction of the text.
  • end: The text will be aligned with the end edge of the containing box. This could be left or right depending on the direction of the text.
  • left: The text will be aligned with the left edge of the containing box.
  • center: The text will be horizontally centered within the containing box.
  • right: The text will be aligned to the right of the containing box.

string (in) default: ""

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

length (in-out) default: 0px

The width of the viewport of the text edit.

length (in-out) default: 0px

The height of the viewport of the text edit.

length (in-out) default: 0px

The x position of the viewport relative to the text edit. This is usually a negative value.

length (in-out) default: 0px

The y position of the viewport relative to the text edit. This is usually a negative value.

length (out)

The width of the visible area of the text edit (not including the scrollbar)

length (out)

The height of the visible area of the text edit (not including the scrollbar)

  • focus() Call this function to focus the TextEdit and make it receive future keyboard events.
  • clear-focus() Call this function to remove keyboard focus from this TextEdit if it currently has the focus. See also focus handling.
  • set-selection-offsets(int, int) Selects the text between two UTF-8 offsets.
  • select-all() Selects all text.
  • clear-selection() Clears the selection. This function takes effect regardless of the read-only and enabled properties.
  • copy() Copies the selected text to the clipboard.
  • cut() Copies the selected text to the clipboard and removes it from the editable area. This function takes effect regardless of the read-only and enabled properties.
  • paste() Pastes the text content of the clipboard at the cursor position. This function takes effect regardless of the read-only and enabled properties.

Emitted when the text has changed because the user modified it

TextEdit {
edited(text) => {
debug("Edited: ", text);
}
}
slint

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

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


© 2026 SixtyFPS GmbH