Combo box -- searchable dropdown with free-form text input.
The renderer manages an internal combo_box::State cache keyed by node ID.
Options changes trigger a state rebuild.
Props
options(list of strings) -- the available choices.selected(string | nil) -- the currently selected value.placeholder(string) -- placeholder text.width(length) -- widget width. Default: fill. SeeToddy.Iced.Length.padding(number | map) -- internal padding. SeeToddy.Iced.Padding.size(number) -- text size in pixels.font(string | map) -- font specification. SeeToddy.Iced.Font.line_height(number | map) -- text line height.menu_height(number) -- maximum height of the dropdown menu in pixels.icon(map) -- display an icon inside the text input. Same format asToddy.Iced.Widget.TextInputicon prop.on_option_hovered(boolean) -- when true, emits%Widget{type: :option_hovered, id: id, value: value}when hovering over a dropdown option. Default: false.shaping-- text shaping strategy. SeeToddy.Iced.Shaping.ellipsis(string) -- text ellipsis strategy:"none","start","middle", or"end". Default:"end".menu_style(map) -- inline style for the dropdown menu. Map with optional keys:background,text_color,selected_text_color,selected_background,border,shadow.style-- named preset atom (:default) orStyleMap.t()for custom styling. SeeToddy.Iced.StyleMap.a11y(map) -- accessibility overrides. SeeToddy.Iced.A11y.
Events
%Widget{type: :select, id: id, value: value}-- emitted when an option is selected.%Widget{type: :input, id: id, value: value}-- emitted on every text input change (for filtering).%Widget{type: :option_hovered, id: id, value: value}-- emitted on hover (requireson_option_hoveredprop).%Widget{type: :open, id: id}-- emitted when the dropdown menu is opened (requireson_open: true).%Widget{type: :close, id: id}-- emitted when the dropdown menu is closed (requireson_close: true).
Summary
Functions
Sets accessibility annotations.
Converts this combo box struct to a ui_node() map via the Toddy.Iced.Widget protocol.
Sets the text ellipsis strategy.
Sets the font.
Sets the icon displayed inside the text input.
Sets the text line height.
Sets the maximum dropdown menu height in pixels.
Sets the dropdown menu style overrides.
Creates a new combo box struct with the given options and optional keyword opts.
Enables or disables the close event when the dropdown menu closes.
Enables or disables the open event when the dropdown menu opens.
Enables or disables option hover event emission.
Sets the internal padding.
Sets the placeholder text.
Sets the currently selected value.
Sets the text shaping strategy.
Sets the text size in pixels.
Sets the combo box style. Accepts :default or a StyleMap.
Sets the combo box width.
Applies keyword options to an existing combo box struct.
Types
@type option() :: {:selected, String.t()} | {:placeholder, String.t()} | {:width, Toddy.Iced.Length.t()} | {:padding, Toddy.Iced.Padding.t()} | {:size, number()} | {:font, Toddy.Iced.Font.t()} | {:line_height, number() | map()} | {:menu_height, number()} | {:icon, map()} | {:on_option_hovered, boolean()} | {:on_open, boolean()} | {:on_close, boolean()} | {:shaping, Toddy.Iced.Shaping.t()} | {:ellipsis, String.t()} | {:menu_style, map()} | {:style, style()} | {:a11y, Toddy.Iced.A11y.t()}
@type style() :: :default | Toddy.Iced.StyleMap.t()
@type t() :: %Toddy.Iced.Widget.ComboBox{ a11y: Toddy.Iced.A11y.t() | nil, ellipsis: String.t() | nil, font: Toddy.Iced.Font.t() | nil, icon: map() | nil, id: String.t(), line_height: number() | map() | nil, menu_height: number() | nil, menu_style: map() | nil, on_close: boolean() | nil, on_open: boolean() | nil, on_option_hovered: boolean() | nil, options: [String.t()], padding: Toddy.Iced.Padding.t() | nil, placeholder: String.t() | nil, selected: String.t() | nil, shaping: Toddy.Iced.Shaping.t() | nil, size: number() | nil, style: style() | nil, width: Toddy.Iced.Length.t() | nil }
Functions
@spec a11y(combo_box :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()
Sets accessibility annotations.
@spec build(combo_box :: t()) :: Toddy.Iced.ui_node()
Converts this combo box struct to a ui_node() map via the Toddy.Iced.Widget protocol.
Sets the text ellipsis strategy.
@spec font(combo_box :: t(), font :: Toddy.Iced.Font.t()) :: t()
Sets the font.
Sets the icon displayed inside the text input.
Sets the text line height.
Creates a new combo box struct with the given options and optional keyword opts.
Enables or disables the close event when the dropdown menu closes.
Enables or disables the open event when the dropdown menu opens.
Enables or disables option hover event emission.
@spec padding(combo_box :: t(), padding :: Toddy.Iced.Padding.t()) :: t()
Sets the internal padding.
Sets the placeholder text.
Sets the currently selected value.
@spec shaping(combo_box :: t(), shaping :: Toddy.Iced.Shaping.t()) :: t()
Sets the text shaping strategy.
Sets the text size in pixels.
Sets the combo box style. Accepts :default or a StyleMap.
@spec width(combo_box :: t(), width :: Toddy.Iced.Length.t()) :: t()
Sets the combo box width.
Applies keyword options to an existing combo box struct.