Input
A single-line text input field with validation states and placeholder support.
Primitive: TextInput
ARIA: role="textbox"
Keyboard: Standard text input
input_example.rs
use stratum_leptos::*;
view! {
<Input placeholder="Enter your email" />
<Input disabled=true placeholder="Disabled" />
<Input value="With value" readonly=true />
}
Installation
stratum add inputInput Types
types.rs
<Input input_type=InputType::Text placeholder="Text" />
<Input input_type=InputType::Email placeholder="Email" />
<Input input_type=InputType::Password placeholder="Password" />
<Input input_type=InputType::Search placeholder="Search..." />
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| value | Option<String> | None | Controlled value |
| default_value | String | "" | Initial value for uncontrolled usage |
| placeholder | Option<String> | None | Placeholder text |
| input_type | InputType | Text | Input type: Text, Email, Password, Search, Tel, Url |
| disabled | bool | false | Prevents interaction |
| readonly | bool | false | Prevents editing but allows focus |
| required | bool | false | Marks as required for form validation |
| on_change | Option<Callback<String>> | None | Fires when value is committed (blur/enter) |
| on_input | Option<Callback<String>> | None | Fires on every keystroke |
| class | Option<String> | None | Additional CSS classes |
Accessibility
- Renders with
role="textbox"(orrole="searchbox"for Search type). - Supports
aria-disabled,aria-readonly,aria-required, andaria-placeholder. - Label association via
aria-labelledbywhen used inside a FormField.