diff --git a/yew-components/src/select.rs b/yew-components/src/select.rs index 1e1a003993a..45f983bac34 100644 --- a/yew-components/src/select.rs +++ b/yew-components/src/select.rs @@ -66,6 +66,15 @@ pub struct Props { /// Options are available to choose. #[prop_or_default] pub options: Vec, + /// Classes applied to the `` tag + #[prop_or_default] + pub id: String, + /// Placeholder value, shown at the top as a disabled option + #[prop_or(String::from("↪"))] + pub placeholder: String, /// Callback to handle changes. pub on_change: Callback, } @@ -124,9 +133,15 @@ where }; html! { - { for self.props.options.iter().map(view_option) } @@ -160,4 +175,28 @@ mod tests { on_change=on_change /> }; } + + #[test] + fn can_create_select_with_class() { + let on_change = Callback::::default(); + html! { + on_change=on_change class="form-control" /> + }; + } + + #[test] + fn can_create_select_with_id() { + let on_change = Callback::::default(); + html! { + on_change=on_change id="test-select" /> + }; + } + + #[test] + fn can_create_select_with_placeholder() { + let on_change = Callback::::default(); + html! { + on_change=on_change placeholder="--Please choose an option--" /> + }; + } }