-
Notifications
You must be signed in to change notification settings - Fork 9
Component ComboBox
MeowLynxSea edited this page Jun 18, 2026
·
6 revisions
A text input combined with a dropdown. As the user types, options filter; Enter picks the highlighted one. The trigger stays editable after a pick.
use yororen_ui::headless::combo_box::{combo_box, ComboBoxOption, ComboBoxState};
let combo_state = ComboBoxState::new(&mut **cx);
combo_state.update(cx, |s, _| {
s.set_options(vec![
ComboBoxOption::new("rust", "Rust"),
ComboBoxOption::new("python", "Python"),
]);
s.set_placeholder("Pick a language…");
s.set_on_change({
let entity = cx.entity();
move |value, _, cx| entity.update(cx, |s, _| s.language = value.to_string());
});
});
combo_box("lang-picker", combo_state).render(cx, window)| Method | Purpose |
|---|---|
new(app) |
Mint a fresh state. Returns Entity<Self>. |
open() / close() / toggle()
|
Show or hide the dropdown. |
is_open() / is_visible()
|
Current state. |
set_text(t) |
Programmatically set the input text. |
set_value(v) |
Programmatically pick a value (also updates the text). |
set_options(opts) |
Replace the option list. |
set_placeholder(p) |
Hint shown when empty. |
set_on_change(f) |
Fn(SharedString, &mut Window, &mut App) + 'static + Send + Sync. |
highlight(i) / highlight_next() / highlight_prev()
|
Move the highlighted option. |
pick(value, w, cx) |
Pick value (a SharedString); closes + fires on_change. |
select_highlighted(w, cx) |
Pick the currently highlighted option. |
.render(cx, window) is two-arg and returns AnyElement (the trigger is a real text input). Typing in the trigger opens the dropdown. set_options(...) takes Vec<ComboBoxOption>.
Yororen UI v0.3.0 · repository · Apache-2.0 · This wiki documents Yororen UI v0.3.0.
This wiki documents Yororen UI v0.3.0 — the headless-core, swappable-renderer build.