Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SearchField

Layer: molecule · Path: src/molecules/search_field.rs · Exports: search_field::SearchField

A search input preset: a thin wrapper over InputGroup configured with a leading magnifier icon. Inspired by Unity’s Search Field.

Design

  • Purpose / when to use — Any filter/search box. Use it instead of hand-wiring an InputGroup with a search glyph.
  • Anatomy — An InputGroup bound to your buffer, with leading_icon(light::MAGNIFYING_GLASS) and an optional placeholder.
  • Tokens / layout consumed — inherited from InputGroup. See tokens.

API

MethodEffect
SearchField::new(buf: &'a mut String) -> SelfBind the search buffer.
.placeholder(text: impl Into<String>) -> SelfHint text shown when empty.
.show(self, ui: &mut Ui) -> ResponseRender; returns the field Response (.changed() on edit).

Usage

#![allow(unused)]
fn main() {
use ouroboros_ui::molecules::SearchField;

// minimal
SearchField::new(&mut query).show(ui);
}
#![allow(unused)]
fn main() {
use ouroboros_ui::molecules::SearchField;

// with placeholder; react to edits
if SearchField::new(&mut query)
    .placeholder("Search assets…")
    .show(ui)
    .changed()
{
    refilter(&query);
}
}

Composition

Composes InputGroup only (which in turn composes Surface + Icon + the text editor). It never paints — see the guards.

Notes

  • A deliberately minimal molecule — no id_source setter; the underlying InputGroup falls back to egui’s auto id. If you need a stable id or trailing clear button, use InputGroup directly.
  • The returned Response is the field’s; .changed() fires on edit.