- Docs
- enzUI framework
- Developers
Text and text input
Displaying text with the type scale, text fields and editors, spell checking, emoji, access keys, selection, drag and shaping.
This page covers showing text (enz_text and the document renderers) and reading it back (fields, editors and the extras around them). See every widget in the widget catalog.

Showing text
enz_text draws text with the theme's type scale, semantic weights and tones:
enz_text(format!("Clicked {} times", self.count))
.size(TextSize::Title3)
.into_element()TextSize names semantic rungs (Caption2, Caption, Footnote, Subheadline, Callout, Body, Headline, Title3, Title2, Title1, LargeTitle, plus Xs to Xl). Each rung takes its weight from the theme (weight_regular to weight_extrabold) and scales with the desktop's text size, so prefer a rung over .size_px(..). A pixel pin keeps its size under the text scale, which is what a document zoom control wants. TextAlign::Start is the default and becomes the right edge in a right-to-left locale.
Text that does not fit elides with an ellipsis, and every enz_text publishes its full value to assistive technology so nothing is lost silently.
For more than a line, reach for:
| Widget | Use |
|---|---|
enz_label | Icon, title and optional subtitle |
enz_labeled_content | A form "label: value" row |
enz_text_pair | Leading text with protected trailing metadata |
enz_section_header | A muted caption above a group or sidebar rail |
enz_markdown | A token-aware Markdown renderer |
enz_reading_pane | Long-form documents |
enz_code_block | A code snippet with a copy chip |
enz_paged_text_viewer | Very large files, paged without indexing the whole file |
enz_streaming_text | Wrapping text with a caret while it streams in |
enz_selection_scope | Read-only text the user can select and copy across widgets |
Fields
Every input is controlled: it takes the current value and a message constructor, and the application stores what the user typed. Widgets keep only interaction state such as focus and cursor position.
enz_text_field("Name or email", "", &self.name, Message::Name).into_element()The arguments are the label, the placeholder, the current value and the message for each edit. Labels, placeholders and validation captions accept owned strings, so translated text can go straight in.
| Widget | Use |
|---|---|
enz_text_field | Single-line input; enz_text_field_owned takes an owned value for retained subtrees |
enz_secure_field(value, on_input, revealed, on_toggle) | Masked input with a reveal toggle; warns when Caps Lock is on |
enz_search_field(value, on_input) | Search input; enz_titlebar_search for a titlebar |
enz_text_area(&content, on_action) | Multi-line editor with an auto-hiding overlay scrollbar |
enz_rich_edit | Rich text with a formatting toolbar, read and written as HTML |
enz_composer | Chat or prompt input: auto-grow, Enter to send, Shift+Enter for a new line, a send button that becomes stop while busy |
enz_chip_input | Turns typed or pasted text into removable chips (tags, recipients) |
enz_input_otp | One-time code or PIN entry |
enz_stepper | A bounded integer or decimal spinbox |
enz_find_replace_bar | Inline find and replace |
enz_time_field, enz_time_picker | Time of day, typed or picked |
FieldVariant::Inline edits in place where a label stood, such as renaming a list row, with no outline or focus ring; the caret and selection mark the edit.
Keep control identity separate from translated text: pin field ids explicitly when labels are translated, because label-derived default ids follow the displayed text.
Spell checking
enz_text_area(..).spell_check(check) underlines misspelled words; right-clicking one offers suggestions, "Add to Dictionary" and "Ignore". enzui_services::spell_check::for_locale() (feature spell-check) picks the dictionary for the locale through Enchant, or reads installed Hunspell dictionaries directly.
Emoji and fonts
emoji_picker::enz_emoji_picker(featureemoji-picker) searches emoji by name and shortcode, with category tabs and recently used emoji.font_chooser::enz_font_chooserlists the installed font families, each in its own font, with styles, a size and a live preview.
Access keys
Builders such as enz_button take .mnemonic(true): the label "_Send" underlines the S, and Alt+S activates the control. Holding Alt shows the access keys. The text_input_extras example (feature emoji-picker) shows emoji, access keys and the Caps Lock warning together.
Selection, clipboard and drag
- Text fields, text areas and the editor offer a finished selection as the primary selection and paste it at the pointer on a middle click, with nothing to wire.
- On Wayland,
app_setup::runinstalls the clipboard on the application's own connection: text, HTML, images and file lists. A copy normally lives in the copying process; when the event loop ends,app_setup::runhands what the app still owns to a keeper so it survives the app's exit where the compositor offersext_data_control_v1. - Selected text drags out of fields and editors and dropped text goes in where it lands, between widgets and other applications. Hold Ctrl to copy instead of move. See Drag and drop.
Right-to-left and mixed text
Single-line fields move the caret on screen through right-to-left and mixed text: Left moves left whatever the storage order, and Ctrl+Left jumps words in the line's direction. Text and search fields mirror in a right-to-left locale, and each takes .direction(..) to override it.
Text shaping
EnzText and MeasureTypography share a TextShaping policy:
Auto(the default) uses basic shaping for ASCII and advanced shaping for anything else.Advancedgives kerning, ligatures and complex-script shaping. Request it for prose, so widths and wrap points do not change because a translation introduced one non-ASCII character.Basicsuits only text whose font and characters you control, such as some ASCII code. It does no font fallback or complex-script shaping.
Use the same policy for measuring and drawing a string; changing it can change glyphs, advances and wrapping. iced's span-based rich text always uses advanced shaping.
Measuring text
enz_text_measure and its variants return font-backed wrapped text height, line counts and byte break offsets, for layouts that must know how tall text will be before drawing it. When ThemeIntegration reports a new theme_generation(), invalidate caches that hold font metrics.