Inline edit

Switches a text value into an editor with explicit save and cancel, validation, and optional async persistence.

Project name
Field study

Change a detail

Project settings

Edit where the value lives. Save commits it; Escape leaves it as it was.

Project name
Field study

Use it for

  • A short text value edited in its reading context.
  • Provide onSave to await persistence before committing a new value.

Not for

  • Long-form writing; use Textarea.
  • Implicit save-on-blur flows; this requires an explicit save.

Three ways in. They share one source, so the pixels match whichever you pick.

1. Import the package

npm install @noorddev/vlak-react

// once, next to your app's root
import "@noorddev/vlak-react/css";

import { InlineEdit } from "@noorddev/vlak-react";

Precompiled React and one stylesheet. No compiler to configure. Per-component imports work too: @noorddev/vlak-react/components/inline-edit.

2. Vendor the source

npx @noorddev/vlak-cli add inline-edit

The StyleX leaf lands in components/vlak/ with its dependencies, for your own compiler to own. See StyleX.

3. Through shadcn

npx shadcn add https://vlak.dev/r/inline-edit.json

The same registry item, installed by shadcn's CLI.

CSS only

<link rel="stylesheet" href="node_modules/@noorddev/vlak/css/vlak.css" />

No React. Link vlak.css and use the markup and classes below.

import { InlineEdit } from "@noorddev/vlak-react";

<InlineEdit label="Project name" name="project" defaultValue="Field study" validate={(value) => value.trim() ? undefined : "Enter a project name"} />

InlineEdit

PropTypeDefaultDescription
valuestring
defaultValuestring""
onValueChange(value: string) => void
labelstring"Value"
namestring
disabledboolean
placeholderstring"Not set"
validate(value: string) => string
onSave(value: string) => void | Promise<void>Resolves before the value is committed. Rejections leave the draft editable.
editLabelstring"Edit"
saveLabelstring"Save"
cancelLabelstring"Cancel"

Also accepts Omit<HTMLAttributes<HTMLDivElement>, "onChange" | "defaultValue">.

KeysDoes
Enter, Space on EditOpens the editor, focuses the input and selects its text.
Enter in the editorValidates and saves without submitting the enclosing form.
Escape in the editorDiscards the draft and returns focus to Edit.
<div class="rs-inline-edit"><span class="rs-inline-edit-label">Project name</span><div class="rs-inline-edit-row"><span class="rs-inline-edit-value">Field study</span><button class="rs-btn-ghost rs-inline-edit-action" type="button" aria-label="Edit Project name">Edit</button></div></div>
.rs-inline-edit.rs-inline-edit-row.rs-inline-edit-label.rs-inline-edit-value.rs-inline-edit-input.rs-inline-edit-action.rs-inline-edit-error