Skip to content

Input

Edit a controlled single-line string.

On this page

Available with egui, Masonry and GPUI through the same public component API. Platform input and accessibility coverage still have alpha limits.

Usage

Replace src/App.iru in a scaffolded project with this complete file, then run cargo run. Keep the scaffold's main.rs and build.rs; this file includes its state, handlers and scoped styles.

src/App.iru
<view>
    <Column class="example">
        <Text text="Workspace name" />
        <Input model:value={name} placeholder="Enter a name" disabled={locked} class="editor" />
        <Checkbox label="Disable the input" model:checked={locked} />
        <Text text={format!("Current name: {}", name)} />
        <Button text="Reset name" @click={reset} class="action" />
    </Column>
</view>
<rust>
use inrux::prelude::*;

let name: String = "Inrux Workspace".into();
let locked: bool = false;

/// Reset the controlled value and restore editing.
fn reset(state: &mut State, _: &Context<State>) {
    state.name = "Inrux Workspace".into();
    state.locked = false;
}
</rust>
<style scoped>
.example {
    padding: 24px;
    gap: 16px;
}
.action {
    background: #b84200;
    color: white;
    padding: 12px;
    border-radius: 6px;
}
.action:hover {
    background: #913400;
}
.action:focus-visible {
    border-width: 2px;
    border-color: #262626;
}
.editor {
    width: 320px;
}
</style>

API Reference

Props

PropTypeDefaultDescription
valueString-like expressionRequired without model:valueControlled single-line value.
model:valueretained field: String or Signal<String>Not setTwo-way value binding; use instead of value.
placeholderString-like expression""Hint displayed when empty.
disabledboolfalsePrevent editing.

Common props

PropTypeDefaultDescription
idString-like expressionNot setStyle-selector identity; independent of retained mount identity.
classString-like expressionNot setWhitespace-separated stylesheet classes.
styleStyleNot setExplicit Rust style overrides for this node.
keyString-like expressionNot setRetained sibling identity; preserve it while reordering children.
widthSizeComponent styleExplicit width constraint; otherwise use the resolved style.
heightSizeComponent styleExplicit height constraint; otherwise use the resolved style.
paddingf32Component styleUniform padding in logical pixels; otherwise use the resolved style.
gapf32Component styleChild spacing in logical pixels; otherwise use the resolved style.

“Component style” means the attribute is omitted and the normal style cascade supplies the value. Application styles can override framework defaults.

Emits

EventPayloadDescription
@inputStringNew single-line value. Required without a model; a model listener runs after assignment.

Bind events with @event={handler}. Ordinary handlers receive &mut State and &Context<State>; controlled value handlers can also receive the listed payload. With model:value or model:checked, the setter runs before the optional model listener, which reads the updated state. Stateless children forward a typed Emit<T>.

Behavior

Input and the TextInput alias are single-line. Hard line breaks in supplied, clipboard and IME text normalize to spaces. The internal horizontal viewport follows the caret for long values. Do not set container overflow styles on the editor itself.

Styling and limits

Use root dimensions and ::part(placeholder) for placeholder color. Associate a visible application label with the control; a placeholder is not a complete labeling strategy. Native editing/IME and accessibility still need platform validation.

Read the detailed reference for validation and native integration details. The playgrounds include a working Input specimen with its surrounding state and reset controls.

Inrux · Built with Nuxt Content, IPEX, and Akaza UI.