Inline edit
Rename in place: the text becomes a field without moving, saves optimistically with a drawn check, and rolls back with Retry when the save fails.
oxyn add inline-editrsx! {
InlineEdit {
value: name(),
label: "Project name",
max: Some(40),
on_save: move |next: String| spawn(save_name(next)),
}
}Rendered from Rust at build time · goes live when visible
When to use
- Rename a project, a thread or an agent; fix a task description where it is.
- The user wants the text to become editable without a jump and trusts the save to land or tell them it didn't.
When not to use
- One input for every form: use Text Field instead.
- Eight variants and five sizes, with a shimmering loading state, a progress fill, press-and-hold for destructive actions and a shortcut chip: use Button instead.
- An assistant docked beside a page: use AI side panel instead.
Installation
Inline edit is free and MIT. The oxyn CLI copies its code, and the components it needs, into src/oxyn/ of your Dioxus or GPUI project, so it is yours to change.
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add inline-edituse crate::oxyn::{InlineEdit, PRIMITIVES_CSS};Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{InlineEdit, PRIMITIVES_CSS};
Usage
rsx! {
InlineEdit {
value: name(),
label: "Project name",
max: Some(40),
on_save: move |next: String| spawn(save_name(next)),
}
}Examples
Title
A project name.
Code
rsx! {
InlineEdit {
value: name(),
label: "Project name",
max: Some(40),
on_save: move |next: String| spawn(save_name(next)),
}
}Body
A description that grows.
Code
rsx! {
InlineEdit {
value: name(),
label: "Project name",
variant: "body",
max: Some(40),
on_save: move |next: String| spawn(save_name(next)),
}
}Rollback
The save fails and rolls back.
Code
rsx! {
InlineEdit {
value: name(),
label: "Project name",
max: Some(40),
on_save: move |next: String| spawn(save_name(next)),
}
}Suggestions
Rename suggestions (Oxyn plus).
Code
rsx! {
InlineEdit {
value: name(),
label: "Project name",
max: Some(40),
on_save: move |next: String| spawn(save_name(next)),
}
}Conflict
The agent edits too (Oxyn plus).
Code
rsx! {
InlineEdit {
value: name(),
label: "Project name",
max: Some(40),
on_save: move |next: String| spawn(save_name(next)),
}
}API reference
InlineEdit
| Prop | Type | Default | Description |
|---|---|---|---|
valuerequired | String | — | The saved value. |
labelrequired | String | — | Accessible name (`Project name`). |
placeholder | String | Default::default() | Shown when empty. |
multiline | bool | Default::default() | Wraps and grows. |
variant | String | "title" | `title` · `body`. |
max | Option<usize> | Default::default() | Max characters. |
suggestions | Vec<String> | Default::default() | Oxyn plus: rename suggestions. |
latency_ms | u32 | 600 | Save latency in ms (the host's promise; 0 = instant). |
fail | bool | Default::default() | The next save fails (demo / test of the rollback). |
conflict | Option<String> | Default::default() | Oxyn plus: simulate the agent renaming it while you edit. |
on_save | EventHandler<String> | — | Persist. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| EnterorSpace | On the text: start editing |
| Enter | Save (Shift+Enter breaks a line in multiline) |
| Esc | Cancel and roll the text back |
| Tab | Leaving saves, like a rename |
Accessibility
- The resting text is a button named “Project name: Atlas”.
- The field has aria-label and aria-invalid; errors are linked with aria-describedby.
- Saving and results go to a status region; Save and Cancel are labelled.
From the spec
At rest the text is a real button whose name includes the label and value. The field has an explicit label and aria-invalid. Saving, saved and failed go to a status region; conflicts use role=alert. Save and Cancel are labelled icon buttons that keep focus in the field (mousedown prevented).
Motion & interaction
The field uses the text's own font and padding so nothing moves when editing starts. The value rolls up on a change and down on a rollback. The check draws, then fades. The pencil fades in on hover only.
Timing
| Transition | Duration | Easing | Reduced motion |
|---|---|---|---|
| Enter edit | 0 ms layout shift | — | — |
| Value roll | 200 ms | ease.out | swap |
| Check draw | 240 ms, visible 1.4 s | ease.out | drawn |
| Pencil | 120 ms fade | ease.out | instant |
Responsive behaviour
- Text wraps and reserves room at the end for Save and Cancel.
- Multiline grows in height as it wraps; on touch a tap starts editing.
Edge cases (spec)
Long titles wrap; the end keeps room for the buttons. Whitespace-only is rejected when required. Multiline trims only trailing space. A save that resolves after another edit started is ignored by phase. Touch: tap edits; no hover pencil. RTL: the buttons sit at the inline end.
Notes for AI
- Import
InlineEditfromoxyn_dioxusand includePRIMITIVES_CSSplus the token stylesheet once. - A GPUI version exists:
InlineEditElinoxyn_gpui. - Props to set first:
value,label. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.