For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
/
3
Sponsor

Search Field

A search input with magnifier icon and clear button.

Import

use maccn::MacSearchField;

Usage

let state = cx.new(|cx| InputState::new(window, cx).placeholder("Search"));
 
MacSearchField::new("search", &state);

Clearing

use gpui::div;
use maccn::{MacLabel, MacSearchField};
use maccn::LabelStyle;
 
div()
    .flex()
    .flex_col()
    .gap_2()
    .child(MacSearchField::new("search-clear", &state).w(px(220.)))
    .child(
        MacLabel::new("search-hint")
            .style(LabelStyle::Footnote)
            .secondary(true)
            .child("Type text to reveal the clear button; press Escape to clear."),
    )

Sizes

use gpui::div;
use maccn::{MacControlSize, MacSearchField};
 
div()
    .flex()
    .items_center()
    .gap_2()
    .child(
        MacSearchField::new("search-xl", &state)
            .size(MacControlSize::ExtraLarge)
            .w(px(240.)),
    )
    .child(
        MacSearchField::new("search-s", &state)
            .size(MacControlSize::Small)
            .w(px(180.)),
    )

Disabled

MacSearchField::new("search-d", &state)
    .disabled(true)
    .w(px(220.))

API

Props

PropTypeDefault
sizeMacControlSizeRegular
disabledboolfalse

InputState

MacSearchField::new(id, &state) requires an Entity<InputState> created with InputState::new(window, cx).