⌂
›
Widgets
›
TextField
TextField
Material text input control for single-line and multi-line entry.
Example
text_field(
label: "Name",
value: "Ruflet"
)
Common properties
labelvaluehint_textpasswordmultilineon_changeon_submit
Usage
status = text(value: "")
text_field(
label: "Name",
on_change: ->(e) { page.update(status, value: e.data.to_s) }
)
Notes
on_changeis commonly used withpage.update(...)- use
multiline: truefor larger text entry areas
Complete API
Helpers
text_field(value = ..., **props)textfield(value = ..., **props)
Accepted properties
adaptive— Adapts to the platform (Material/Cupertino) when true.align— Alignment of the control within its parent.align_label_with_hint— Sets the align label with hint property.always_call_on_tap— Sets the always call on tap property.animate_align— Animates alignment changes.animate_cursor_opacity— Animates cursor opacity changes.animate_margin— Animates margin changes.animate_offset— Animates offset changes.animate_opacity— Animates opacity changes.animate_position— Animates position changes.animate_rotation— Animates rotation changes.animate_scale— Animates scale changes.animate_size— Animates size changes.aspect_ratio— Width-to-height ratio to maintain.autocorrect— Sets the autocorrect property.autofill_hints— Sets the autofill hints property.autofocus— Requests focus when first shown.badge— Badge drawn on the corner of the control.bgcolor— Background color.border— Border definition.border_color— Border color.border_radius— Corner radius.border_width— Border thickness.bottom— Bottom offset when positioned inside a stack.can_request_focus— Sets the can request focus property.can_reveal_password— Sets the can reveal password property.capitalization— Sets the capitalization property.clip_behavior— How content overflowing the bounds is clipped.col— Responsive column span (1-12) per breakpoint.collapsed— Sets the collapsed property.color— Foreground color.content_padding— Content padding.counter— Sets the counter property.counter_style— Counter style.cursor_color— Cursor color.cursor_error_color— Cursor error color.cursor_height— Cursor height.cursor_radius— Cursor radius.cursor_width— Cursor width.data— Arbitrary value you can attach to the control and read back in handlers.dense— Sets the dense property.disabled— Disables interaction when true.enable_ime_personalized_learning— Sets the enable ime personalized learning property.enable_interactive_selection— Sets the enable interactive selection property.enable_stylus_handwriting— Sets the enable stylus handwriting property.enable_suggestions— Sets the enable suggestions property.error— Sets the error property.error_max_lines— Sets the error max lines property.error_style— Error style.expand— Fills the available space along the parent's main axis when true.expand_loose— Like expand, but only grows up to the child's natural size.fill_color— Fill color.filled— Sets the filled property.fit_parent_size— Sets the fit parent size property.focus_color— Color shown while focused.focused_bgcolor— Focused background color.focused_border_color— Focused border color.focused_border_width— Focused border width.focused_color— Focused color.height— Fixed height in logical pixels.helper— Sets the helper property.helper_max_lines— Sets the helper max lines property.helper_style— Helper style.hint_fade_duration— Sets the hint fade duration property.hint_max_lines— Sets the hint max lines property.hint_style— Hint style.hint_text— Placeholder shown when the field is empty.hover_color— Color shown while hovered.icon— Icon name shown by the control.ignore_pointers— Sets the ignore pointers property.ignore_up_down_keys— Sets the ignore up down keys property.input_filter— Sets the input filter property.key— Stable identity used to preserve state across rebuilds.keyboard_brightness— Sets the keyboard brightness property.keyboard_type— On-screen keyboard type (e.g. number, email).label— Text label shown for the control.label_style— Label style.left— Left offset when positioned inside a stack.margin— Outer spacing around the control.max_length— Sets the max length property.max_lines— Sets the max lines property.min_lines— Sets the min lines property.mouse_cursor— Cursor shown when hovering the control.multiline— Allows multiple lines of input when true.obscuring_character— Sets the obscuring character property.offset— Translation offset applied to the control.opacity— Opacity from 0.0 (transparent) to 1.0 (opaque).password— Obscures the entered text when true.prefix— Sets the prefix property.prefix_icon— Prefix icon.prefix_icon_size_constraints— Sets the prefix icon size constraints property.prefix_style— Prefix style.read_only— Prevents editing while still allowing selection.right— Right offset when positioned inside a stack.rotate— Rotation applied to the control.rtl— Renders right-to-left when true.scale— Scale transform applied to the control.scroll_padding— Scroll padding.selection— Sets the selection property.selection_color— Selection color.shift_enter— Sets the shift enter property.show_cursor— Sets the show cursor property.size_change_interval— Throttle interval for on_size_change, in ms.size_constraints— Min/max size constraints.smart_dashes_type— Sets the smart dashes type property.smart_quotes_type— Sets the smart quotes type property.strut_style— Strut style.suffix— Sets the suffix property.suffix_icon— Suffix icon.suffix_icon_size_constraints— Sets the suffix icon size constraints property.suffix_style— Suffix style.text_align— Sets the text align property.text_size— Sets the text size property.text_style— Text style.text_vertical_align— Sets the text vertical align property.tooltip— Text shown on hover/long-press.top— Top offset when positioned inside a stack.value— The control's current value.visible— Hides the control when false.width— Fixed width in logical pixels.
Events
on_animation_end— Fired when an animation completes.on_blur— Fired when the control loses focus.on_change— Fired when the value changes.on_click— Fired when the control is clicked/tapped.on_focus— Fired when the control gains focus.on_selection_change— Fired when the selection range changes.on_size_change— Fired when the control's size changes.on_submit— Fired when the input is submitted.on_tap_outside— Fired when a tap occurs outside the control.
Wire reference
- Family:
materials - Widget type:
textfield