Skip to content
nexubDesign System
v11.9.0

Components · Form & Input

Inline Edit

BetaAdded v6.1.0

Text that becomes an input on click, for renaming things in place.

import { InlineEdit } from '@nexub/react';
View as Markdown

Playground

Props

TSX
<InlineEdit value={name} onSave={…} label="Project name" placeholder="Add a name" />

Examples

Rename

Editable page title

A headline inside an `h2`, capped at 40 characters.

States

  • default
  • disabled
  • size="title"
  • size="sm"
  • size="md"
  • size="lg"
  • size="headline"

Props

Props
PropTypeDefaultDescription
valuerequiredstring—The saved text.
onSaverequired(value: string) => void | Promise<unknown>—Called on Enter or blur when the text changed. A promise keeps the field open and busy; a rejection keeps it open and invalid.
labelrequiredstring—Names the input, and the button reads "Edit ‹label›, ‹value›".
placeholderstring—Shown when the value is empty.
disabledboolean—Shows the text without editing.
size'title' | 'sm' | 'md' | 'lg' | 'headline''md' (or the `as` element's own type when `as` is set)11.5. Type role of the text and the input: body small, medium, large, title large or headline small. With as and no size, the text takes the wrapper’s type.
asReact.ElementType<any, keyof React.JSX.IntrinsicElements>—11.5. Wraps the text, and the input while editing, in this element: a heading ("h2") or a component such as Sheet.Title or Dialog.Title, so the heading and the dialog’s name stay in place.
maxLengthnumber—11.5. Caps the input and shows a "12/40" counter, announced near the limit.
classNamestring—

Accessibility

Keyboard

  • Enter / Space

    On the text: starts editing.

  • Enter

    In the input: saves.

  • Escape

    Reverts and returns focus to the text.

Notes

  • Moving focus away saves too. Validate in `onSave` and reject to keep the field open.