InlineEdit

Text that edits in place. A pencil on hover, a field of the same size and type when you press, a tick and cross beside it, and a flash when it saves. Inputs.

Open playground

About

InlineEdit is a React component in the Inputs category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { InlineEdit } from "@ashutoshswamy/smoui" and set validate, label, value among its 5 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { InlineEdit } from "@ashutoshswamy/smoui";

<InlineEdit label="Project name" defaultValue="Motion studies" onChange={setName} />

Props 5

validate

Return a message to refuse the edit; the field stays open and shakes.

(value: string) => string | undefined
label

Accessible edit name.

string
value / defaultValue

Controlled or initial text.

string
onChange

Called when nonempty edited text is saved.

(value: string) => void
placeholder

Shown when value is empty.

stringdefault "Add text"