Client component

Editable

Click-to-edit text for titles, names and inline fields where a permanent input would be visual noise. The preview is a real button in the accessibility tree (Enter/Space start editing); the input auto-focuses with its text selected, commits on Enter or blur, and cancels on Escape.

Q3 launch plan

Import#

import { Editable } from "astralis-ui";

Usage#

Render both parts; whichever matches the current mode shows itself. The preview is a button until you activate it, then the input takes focus with its text selected, so typing replaces the value straight away.

To keep the value in your own state, pass value and onChange. onChange fires on every keystroke, so pair it with onSubmit to know when an edit is final and onCancel to roll back:

Nova Starling

Saved: Nova Starling

Props#

PropTypeDefaultDescription
value / defaultValue / onChangestring / string / (value: string) => voidNone / "" / NoneControlled / uncontrolled text. onChange fires on every keystroke while editing.
onSubmit(value: string) => voidNoneFires when an edit is committed with Enter or blur.
onCancel() => voidNoneFires when an edit is cancelled with Escape.
placeholderstring"Click to edit"Shown in the preview while the value is empty.
size"sm" | "md" | "lg""md"Text scale shared by the preview and the input.
submitOnBlurbooleantrueBlur commits the edit. Turn it off and blur cancels instead.
startWithEditViewbooleanfalseMounts already editing.
disabledbooleanfalseLocks editing; the preview becomes plain text.

Parts#

PropTypeDefaultDescription
Editable.Previewspan propsNoneThe value at rest. A button in the accessibility tree that starts editing.
Editable.Inputinput propsNoneThe text field while editing. Focused with its text selected on entry.

Keyboard#

KeyAction
Enter / Space on the previewStart editing
Enter in the inputCommit the edit
Esc in the inputCancel and restore the previous value
Tab out of the inputCommit, or cancel when submitOnBlur is off