iced-cube

Forms

Textarea

Multi-line text editing that matches the look of Input.

use iced::widget::text_editor;
use iced_cube::textarea;
API reference
Default: Grows with its content, with a character count below.Default: Grows with its content, with a character count below.
Static preview
Default. Grows with its content, with a character count below.

Usage

The textarea wraps iced’s text editor, so your app owns the text_editor::Content and applies every Action it receives. This keeps undo, validation and limits in your own update, as the character count example shows.

Read the text back with content.text(). Wrap the textarea in field to give it a label and helper text.

Examples

Fixed height and disabled

A fixed-height textarea next to one without on_action, which is disabled.

Fixed height and disabled: A fixed-height textarea next to one without on_action, which is disabled.Fixed height and disabled: A fixed-height textarea next to one without on_action, which is disabled.
Static preview

API

ItemDescription
textarea(&content)Creates a textarea editing a text_editor::Content owned by your app. It renders disabled until it has on_action.
.on_action(fn) / .on_action_maybe(option)Sets the message built from each edit action. Apply it with content.perform(action) in update. None disables the textarea.
.placeholder(text)Text shown while the content is empty.
.height(length)Sets the height. By default the textarea starts about three lines tall and grows with its content. A fixed height scrolls once the text overflows.
.min_height(pixels)Sets the starting height used while the height is Shrink. Defaults to 80.
.invalid(bool)Draws a destructive border.
.id(id) / .width(length)Sets the widget id and overrides the width. Textareas fill the available width by default.

Keyboard

KeysBehaviour
EnterInserts a new line.
EscapeRemoves focus from the textarea.
Arrow keys, Home, End, Page Up, Page DownMoves the cursor. Hold Shift to select.
Esc