Skip to main content

text_field

Function text_field 

Source
pub fn text_field() -> TextFieldBuilder
Expand description

§text_field

Render a Material text field for short-form input with optional secure obfuscation.

§Usage

Capture names, email addresses, or passwords with Material defaults.

§Parameters

  • presentation_state — optional visual interaction without changing input or focus.
  • enabled — whether the field accepts user input.
  • read_only — whether the field is read-only.
  • is_error — whether the field is displaying an error state.
  • modifier — optional modifier chain applied to the field container.
  • on_change — optional text change callback.
  • on_submit — optional submit callback for single-line fields.
  • min_width — optional minimum width.
  • min_height — optional minimum height.
  • background_color — optional container background color.
  • border_width — base border width.
  • border_color — optional border color.
  • shape — field container shape.
  • padding — content padding.
  • horizontal_padding — optional horizontal content padding override.
  • focus_border_color — optional focused border color.
  • focus_border_width — optional focused border width.
  • focus_background_color — optional focused background color.
  • selection_color — optional text selection highlight color.
  • text_color — optional text color.
  • cursor_color — optional cursor color.
  • accessibility_label — accessible name; defaults to the visible label.
  • accessibility_description — optional accessibility description.
  • initial_text — optional initial text content.
  • font_size — font size in Dp.
  • style — typography override, including weight and letter spacing.
  • line_height — optional line height in Dp.
  • label — optional label text.
  • placeholder — optional placeholder text.
  • leading_icon — optional leading icon slot.
  • trailing_icon — optional trailing icon slot.
  • prefix — optional prefix slot.
  • suffix — optional suffix slot.
  • show_indicator — whether filled-style indicator is rendered.
  • line_limit — text line limit policy.
  • context_menu — context menu policy.
  • input_transform — optional input transform callback.
  • obfuscation_char — optional obfuscation character.
  • display_transform — optional display transform.
  • controller — optional external text input controller.

§Examples

use tessera_components::text_field::text_field;
use tessera_ui::CallbackWith;
let transform = CallbackWith::new(|value: String| value.to_uppercase());
assert_eq!(transform.call("hello".to_string()), "HELLO");
text_field().input_transform_shared(transform);