use dioxus::prelude::*;
#[component]
pub fn SearchInput(
value: String,
on_input: EventHandler<String>,
placeholder: Option<String>,
) -> Element {
let placeholder_text = placeholder.unwrap_or_else(|| "Search...".to_string());
rsx! {
div {
class: "search-input",
span { class: "search-input__icon", "🔍" }
input {
class: "search-input__field",
r#type: "text",
placeholder: "{placeholder_text}",
value: "{value}",
oninput: move |evt| on_input.call(evt.value()),
}
if !value.is_empty() {
button {
class: "search-input__clear",
onclick: move |_| on_input.call(String::new()),
"✕"
}
}
}
}
}