Fusuma

Components / Basics

text_field

A text field holding value.

Try it

This is the Text page of the gallery, running in your browser: text_field is on it, and it is the real widget. Press Run, then use it.

Live: Text, where text_field is usedOpen full size

Also on this pageform_field

A text field holding value.

One line of text (.rows(n) makes it an area of n lines). .on_input(f) sends the whole new text on every edit, .on_submit(message) the Enter key; .placeholder(..) shows while it is empty. The app keeps the text and gives it back, so it can refuse or change what was typed.

Signature

pub const fn text_field<M>(value: &str) -> TextField<'_, M>

Methods

  • .placeholder(text: &'static str) -> Self — Shown, muted, while it is empty.
  • .rows(rows: u8) -> Self — Makes it a text area of rows lines (at least 2): Enter breaks the line instead of submitting, Up and Down move between lines.
  • .on_submit(message: M) -> Self — Sends message when Enter is pressed in the field.
  • .on_input(f: fn(&str) -> M) -> Self — Sends a message made from the new text whenever it changes.

Example

use fusuma::{column, text_field};
let name = "Ada";
let view = column((text_field(name).placeholder("Your name").on_input(|_| ()),));
let built = fusuma::doc::built::<(), _>(&view);
assert_eq!(built.nodes(), 2);

All components · Source