Text input field -- single-line editable text.
Emits %Widget{type: :input, id: id, value: value} on every keystroke.
Props
value(string) -- current text content. Required for controlled input.placeholder(string) -- placeholder text shown when value is empty.padding(number | map) -- internal padding. SeeToddy.Iced.Padding.width(length) -- input width. Default: fill. SeeToddy.Iced.Length.size(number) -- font size in pixels.font(string | map) -- font specification. SeeToddy.Iced.Font.line_height(number | map) -- line height. Number is a relative multiplier; map with%{relative: n}or%{absolute: n}for explicit control.align_x(atom) -- text horizontal alignment::left,:center,:right. SeeToddy.Iced.Alignment.on_submit(any) -- when present (any truthy value), enables submit on Enter. Emits%Widget{type: :submit, id: id, value: value}.id(string) -- widget ID for programmatic focus viaToddy.Command.focus/1.style(atom) -- named style. Currently only:default.icon(map) -- display an icon inside the input field. Map with keys:code_point(string) -- single character to render as the icon. Required.size(number) -- icon font size in pixels. Optional.spacing(number) -- pixels between icon and text. Default: 4.0.side(string) --"left"or"right". Default:"left".font(string | map) -- icon font. Default: system default.
on_paste(boolean) -- when true, emits%Widget{type: :paste, id: id, value: text}when user pastes text. Default: false.secure(boolean) -- mask input as password dots. Default: false.ime_purpose(string) -- IME input purpose hint:"normal","secure","terminal". Overrides the default derived fromsecure. Default: nil (auto fromsecure).placeholder_color(color) -- placeholder text color. SeeToddy.Iced.Color.selection_color(color) -- text selection highlight color. SeeToddy.Iced.Color.a11y(map) -- accessibility overrides. SeeToddy.Iced.A11y.
Events
%Widget{type: :input, id: id, value: value}-- emitted on every text change.%Widget{type: :submit, id: id, value: value}-- emitted on Enter (requireson_submitprop).%Widget{type: :paste, id: id, value: text}-- emitted on paste (requireson_pasteprop).
Summary
Functions
Sets accessibility annotations.
Sets the horizontal text alignment.
Converts this text input struct to a ui_node() map via the Toddy.Iced.Widget protocol.
Sets the font.
Sets the icon displayed inside the input field.
Sets the IME input purpose hint. Overrides the default derived from secure.
Sets the line height.
Creates a new text input struct with the given value and optional keyword opts.
Enables or disables paste event emission.
Enables or disables submit on Enter.
Sets the internal padding.
Sets the placeholder text.
Sets the placeholder text color. Accepts any form Color.cast/1 supports.
Sets whether input is masked as a password.
Sets the text selection highlight color. Accepts any form Color.cast/1 supports.
Sets the font size in pixels.
Sets the input style.
Sets the input width.
Applies keyword options to an existing text input struct.
Types
@type option() :: {:placeholder, String.t()} | {:padding, Toddy.Iced.Padding.t()} | {:width, Toddy.Iced.Length.t()} | {:size, number()} | {:font, Toddy.Iced.Font.t()} | {:line_height, number() | map()} | {:align_x, Toddy.Iced.Alignment.t()} | {:icon, map()} | {:on_submit, boolean()} | {:on_paste, boolean()} | {:secure, boolean()} | {:ime_purpose, String.t()} | {:style, style()} | {:placeholder_color, Toddy.Iced.Color.input()} | {:selection_color, Toddy.Iced.Color.input()} | {:a11y, Toddy.Iced.A11y.t()}
@type style() :: :default | Toddy.Iced.StyleMap.t()
@type t() :: %Toddy.Iced.Widget.TextInput{ a11y: Toddy.Iced.A11y.t() | nil, align_x: Toddy.Iced.Alignment.t() | nil, font: Toddy.Iced.Font.t() | nil, icon: map() | nil, id: String.t(), ime_purpose: String.t() | nil, line_height: number() | map() | nil, on_paste: boolean() | nil, on_submit: boolean() | nil, padding: Toddy.Iced.Padding.t() | nil, placeholder: String.t() | nil, placeholder_color: Toddy.Iced.Color.t() | nil, secure: boolean() | nil, selection_color: Toddy.Iced.Color.t() | nil, size: number() | nil, style: style() | nil, value: String.t(), width: Toddy.Iced.Length.t() | nil }
Functions
@spec a11y(text_input :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()
Sets accessibility annotations.
@spec align_x(text_input :: t(), align_x :: Toddy.Iced.Alignment.t()) :: t()
Sets the horizontal text alignment.
@spec build(text_input :: t()) :: Toddy.Iced.ui_node()
Converts this text input struct to a ui_node() map via the Toddy.Iced.Widget protocol.
@spec font(text_input :: t(), font :: Toddy.Iced.Font.t()) :: t()
Sets the font.
Sets the icon displayed inside the input field.
Sets the IME input purpose hint. Overrides the default derived from secure.
Sets the line height.
Creates a new text input struct with the given value and optional keyword opts.
Enables or disables paste event emission.
Enables or disables submit on Enter.
@spec padding(text_input :: t(), padding :: Toddy.Iced.Padding.t()) :: t()
Sets the internal padding.
Sets the placeholder text.
@spec placeholder_color(text_input :: t(), color :: Toddy.Iced.Color.input()) :: t()
Sets the placeholder text color. Accepts any form Color.cast/1 supports.
Sets whether input is masked as a password.
@spec selection_color(text_input :: t(), color :: Toddy.Iced.Color.input()) :: t()
Sets the text selection highlight color. Accepts any form Color.cast/1 supports.
Sets the font size in pixels.
Sets the input style.
@spec width(text_input :: t(), width :: Toddy.Iced.Length.t()) :: t()
Sets the input width.
Applies keyword options to an existing text input struct.