pub fn Input(_: InputProps) -> ElementExpand description
A single-line text field with a label. Like Ionic’s ion-input.
Pass a value signal to own the text, or leave it out and read changes
from onchange. oninput fires on every keystroke; onchange fires when
the user commits (blur or Enter), or after debounce_ms of no typing when
that is set, which suits search-as-you-type.
let email = use_signal(String::new);
rsx! {
Input {
label: "Email",
value: email,
input_type: InputType::Email,
autocomplete: "email",
required: true,
error: email_error(),
}
}§Props
For details, see the props struct definition.
label:Option<String>Visible label, which also names the field.
aria_label:Option<String>Accessible name when there is no visible label.
value:Option<Signal<String>>The text. Kept internally when not given.
input_type:Option<InputType>The kind of value. Defaults to
InputType::Text.placeholder:Option<String>Hint shown while empty.
helper:Option<String>Help text below the field.
error:Option<String>Error text below the field. Marks the field invalid when not empty.
required:Option<bool>Mark the field required.
disabled:Option<bool>Disable the field.
readonly:Option<bool>Make the field read-only.
min:Option<f64>Smallest number, for
InputType::Number.max:Option<f64>Largest number. Typing past it is refused.
step:Option<f64>Number granularity.
minlength:Option<usize>Shortest valid text, in characters.
maxlength:Option<usize>Longest text, in characters. Typing past it is refused.
autocomplete:Option<String>Browser autofill hint, such as
"email"or"current-password".clearable:Option<bool>Show a button that clears the text.
start:Option<Element>Content inside the field before the text, usually an icon.
end:Option<Element>Content inside the field after the text, such as a unit or a button.
debounce_ms:Option<u64>Delay
onchangeuntil typing pauses for this many milliseconds.oninput:Option<EventHandler<String>>Called with the new text on every keystroke.
onchange:Option<EventHandler<String>>Called with the text when the user commits it, or after the debounce.
id:Option<String>Element id. Generated when not given.
mode:Option<ComponentMode>Platform look. Defaults to the ambient mode.
class:Option<String>Extra classes for the field wrapper.
attributes:Vec<Attribute>Any other attribute for the
<input>, such asnameorinputmode.