MCPcopy Create free account
hub / github.com/DioxusLabs/dioxus-components / SelectValue

Function SelectValue

primitives/src/select/components/value.rs:68–85  ·  view source on GitHub ↗
(props: SelectValueProps)

Source from the content-addressed store, hash-verified

66/// The [`SelectValue`] component defines a span with a `data-placeholder` attribute if a placeholder is set.
67#[component]
68pub fn SelectValue(props: SelectValueProps) -> Element {
69 let ctx = use_context::<SelectContext>();
70
71 let is_empty = move || ctx.selectable.is_empty();
72 let display_value = ctx
73 .selectable
74 .selected_text()
75 .unwrap_or_else(|| props.placeholder.cloned());
76
77 rsx! {
78 // Add placeholder option if needed
79 span {
80 "data-placeholder": is_empty(),
81 ..props.attributes,
82 {display_value}
83 }
84 }
85}

Callers

nothing calls this directly

Calls 2

selected_textMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected