pub struct InputProps {Show 21 fields
pub type: String,
pub value: String,
pub uncontrolled: bool,
pub placeholder: String,
pub min: Option<String>,
pub max: Option<String>,
pub autocomplete: Option<String>,
pub autocorrect: Option<String>,
pub step: Option<String>,
pub accept: Option<String>,
pub list: Option<String>,
pub size: Size,
pub disabled: bool,
pub readonly: bool,
pub oninput: Option<EventHandler<FormEvent>>,
pub onchange: Option<EventHandler<FormEvent>>,
pub onfocus: Option<EventHandler<FocusEvent>>,
pub onblur: Option<EventHandler<FocusEvent>>,
pub onkeydown: Option<EventHandler<KeyboardEvent>>,
pub onkeyup: Option<EventHandler<KeyboardEvent>>,
pub class: String,
/* private fields */
}Expand description
Bootstrap Input component.
§Bootstrap HTML → Dioxus
| HTML | Dioxus |
|---|---|
<input class="form-control" type="text"> | Input { r#type: "text" } |
<input class="form-control form-control-sm" type="email"> | Input { r#type: "email", size: Size::Sm } |
<input class="form-control" disabled> | Input { disabled: true } |
<input class="form-control" list="opts"> | Input { list: "opts" } |
Bind a <datalist> for autocomplete with list, and observe focus with
onfocus / onblur:
rsx! {
Input { r#type: "text", value: "hello", placeholder: "Enter text" }
Input { r#type: "email", size: Size::Sm, oninput: move |evt| { /* handle */ } }
Input { r#type: "password", disabled: true }
Input {
list: "icon-options",
onfocus: move |_| { /* open suggestions */ },
onblur: move |_| { /* close suggestions */ },
}
datalist { id: "icon-options",
option { value: "star" }
option { value: "heart" }
}
}Fields§
§type: StringInput type (text, email, password, number, etc.).
value: StringCurrent value.
uncontrolled: boolWhen true, the value attribute is omitted so the field is
uncontrolled: the DOM keeps whatever value the user or an external
script writes, instead of Dioxus forcing it back to value on every
render. Use for a field another script streams into (e.g. a live
transcript box).
placeholder: StringPlaceholder text.
min: Option<String>Minimum value for numeric/date inputs.
max: Option<String>Maximum value for numeric/date inputs.
autocomplete: Option<String>Browser autocomplete hint.
autocorrect: Option<String>Safari’s autocorrect hint (on / off). Not a GlobalAttributes
attribute, so it needs its own prop rather than riding ..attributes —
the same reason list has one.
step: Option<String>Step granularity for numeric and date inputs. The typed sibling of
min/max, which are already props: a number field that constrains its
range but not its increment is only two-thirds typed.
accept: Option<String>Which file types a type="file" input will accept.
list: Option<String>Datalist id to bind for autocomplete (rendered as the input list
attribute). list is not a GlobalAttributes attribute, so it needs
its own typed prop rather than riding through ..attributes.
size: SizeInput size.
disabled: boolDisabled state.
readonly: boolReadonly state.
oninput: Option<EventHandler<FormEvent>>Input event handler.
onchange: Option<EventHandler<FormEvent>>Change event handler.
onfocus: Option<EventHandler<FocusEvent>>Focus event handler.
onblur: Option<EventHandler<FocusEvent>>Blur event handler.
onkeydown: Option<EventHandler<KeyboardEvent>>Key down event handler.
onkeyup: Option<EventHandler<KeyboardEvent>>Key up event handler.
class: StringAdditional CSS classes.
Implementations§
Source§impl InputProps
impl InputProps
Sourcepub fn builder() -> InputPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
pub fn builder() -> InputPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
Create a builder for building InputProps.
On the builder, call .r#type(...)(optional), .value(...)(optional), .uncontrolled(...)(optional), .placeholder(...)(optional), .min(...)(optional), .max(...)(optional), .autocomplete(...)(optional), .autocorrect(...)(optional), .step(...)(optional), .accept(...)(optional), .list(...)(optional), .size(...)(optional), .disabled(...)(optional), .readonly(...)(optional), .oninput(...)(optional), .onchange(...)(optional), .onfocus(...)(optional), .onblur(...)(optional), .onkeydown(...)(optional), .onkeyup(...)(optional), .class(...)(optional), .attributes(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of InputProps.
Trait Implementations§
Source§impl Clone for InputProps
impl Clone for InputProps
Source§fn clone(&self) -> InputProps
fn clone(&self) -> InputProps
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more