Xzero UI
Pro library

Inline edit

Rename in place: the text becomes a field without moving.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/inline-edit
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/inline-edit

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { InlineEdit } from "@/components/xzero/inline-edit/inline-edit";

export function ProjectTitle({ project }: { project: { id: string; name: string } }) {
  return (
    <InlineEdit
      as="h1"
      label="Project name"
      value={project.name}
      validate={(next) => (next.trim() ? null : "Name can’t be empty")}
      onSave={(next) => renameProject(project.id, next)}
    />
  );
}

API reference

InlineEdit

Click-to-edit text that becomes a field in place with the same metrics, saves optimistically, and rolls back on failure.

PropTypeDefaultDescription
value (required)string–The saved value. Outside changes replace the text while not editing.
onSave (required)(next: string) => void | Promise<unknown>–Persists the value. Return a promise to show saving; reject it to roll back with a retry.
label (required)string–Accessible name, for example "Project name".
validate(next: string) => string | null | undefined–Returns an error message to block saving.
placeholderstring""Shown when the value is empty.
multilinebooleanfalseWraps and grows in height; Shift+Enter adds a line break.
variant"title" | "body""title"Type style: title for names and headings, body for descriptions.
as"span" | "p" | "h1" | "h2" | "h3""span"Element that holds the text, so a title can stay a heading.
classNamestring–Added to the root.

Keyboard interactions

KeysAction
Enter / SpaceOn the text, starts editing.
EnterSaves the draft. In multiline mode, Shift+Enter inserts a line break.
EscapeCancels and rolls the text back.
TabLeaving the component saves, the way a rename does.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in text fields

Guidance for AI tools

Inline edit: Rename in place: the text becomes a field without moving. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components