pub struct Select { /* private fields */ }Expand description
A select with a styled listbox: keyboard navigation, type-ahead, single or
multiple choice. Submits like a native <select> (it is one underneath).
let s = Select![label = "Country", name = "country", value = "in",
SelectItem![value = "in", "India"], SelectItem![value = "us", "United States"]];
let html = render_static(s);
assert!(html.contains(r#"<option value="in" selected>India</option>"#));
assert!(html.contains(r#"role="option""#));Implementations§
Source§impl Select
impl Select
pub fn new() -> Self
pub fn placeholder(self, v: impl Into<String>) -> Self
Sourcepub fn description(self, v: impl MaybeText) -> Self
pub fn description(self, v: impl MaybeText) -> Self
Help text under the field.
Sourcepub fn error_message(self, v: impl MaybeText) -> Self
pub fn error_message(self, v: impl MaybeText) -> Self
Error text under the field; also marks it invalid.
error_message = form.error("email") shows server validation errors.
Sourcepub fn name(self, v: impl Into<String>) -> Self
pub fn name(self, v: impl Into<String>) -> Self
Form field name. Server-action validation errors for this name appear under the field automatically.
pub fn required(self, v: bool) -> Self
pub fn disabled(self, v: bool) -> Self
pub fn readonly(self, v: bool) -> Self
pub fn size(self, v: Size) -> Self
pub fn variant(self, v: FieldVariant) -> Self
pub fn radius(self, v: Radius) -> Self
pub fn label_placement(self, v: LabelPlacement) -> Self
Sourcepub fn start_content(self, v: impl View) -> Self
pub fn start_content(self, v: impl View) -> Self
Content at the start of the box, typically an icon.
Sourcepub fn end_content(self, v: impl View) -> Self
pub fn end_content(self, v: impl View) -> Self
Content at the end of the box.
Sourcepub fn full_width(self, v: bool) -> Self
pub fn full_width(self, v: bool) -> Self
Take the full width of the container (the default).
Sourcepub fn label_class(self, v: impl Into<String>) -> Self
pub fn label_class(self, v: impl Into<String>) -> Self
Extra classes for the label.
Sourcepub fn wrapper_class(self, v: impl Into<String>) -> Self
pub fn wrapper_class(self, v: impl Into<String>) -> Self
Extra classes for the box around the control.
Sourcepub fn input_class(self, v: impl Into<String>) -> Self
pub fn input_class(self, v: impl Into<String>) -> Self
Extra classes for the control itself.
pub fn description_class(self, v: impl Into<String>) -> Self
pub fn error_class(self, v: impl Into<String>) -> Self
Sourcepub fn class(self, v: impl Into<String>) -> Self
pub fn class(self, v: impl Into<String>) -> Self
Extra classes for the outer element. They win over the defaults.
Sourcepub fn with(self, part: impl SelectPart) -> Self
pub fn with(self, part: impl SelectPart) -> Self
Add options (SelectItem, ("value", "Label")) or attributes for
the control; class(..) goes to the outer element.
Sourcepub fn items(self, v: impl IntoIterator<Item = SelectItem>) -> Self
pub fn items(self, v: impl IntoIterator<Item = SelectItem>) -> Self
Options, as a list.
Sourcepub fn values<S: Into<String>>(self, v: impl IntoIterator<Item = S>) -> Self
pub fn values<S: Into<String>>(self, v: impl IntoIterator<Item = S>) -> Self
Selected values when multiple.