# Inline Edit (Lumen Halo): prompt.md (v1.0.0)

- id: `lumen-inline-edit` · version 1.0.0 · component · pro (Pro)
- category: Inputs
- build: Base UI (one set of files; its dependencies follow the build)
- install (this build): `npx shadcn@latest add @beautiful-ui-pro/lumen-inline-edit`
- npm dependencies: none
- registry dependencies: utils, https://beautiful-ui.dev/r/lumen-foundation.json
- docs: https://beautiful-ui.dev/components/lumen-inline-edit
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

Rename in place: the text becomes a field in exactly the same box, so nothing moves. Enter or leaving saves, Escape puts the old text back, validation says why in place, and a failed save rolls back.

## Build it
- Stack: React 19 (`ref` is a plain prop), TypeScript, Tailwind CSS v4 utilities, a shadcn-initialised project with the `@/*` alias.
- Packages: none beyond React.
- Files: `components/ui/lumen/controls/inline-edit.tsx`.
- Registry dependencies, installed with it automatically: shadcn `utils` (cn), `lumen-foundation`.
- Builds: one set of files for both, but its dependencies come in Base UI and Radix builds. Install the one that matches the project (see Install): a free item's bare URL installs the Base UI build of it and its dependencies.
- Exports to keep: `InlineEdit`, `(text)`, `(field)`, `(reason)`, and every exported type.
- CSS: the install merges this item's rules (the registry `css` field) into your global stylesheet, in `@layer components`, and adds the lumen foundation (tokens, keyframes, motion levels) once. Nothing to import by hand.
- Re-running `add` (or `--overwrite`) re-applies those rules: put overrides in your own CSS, never in the installed rules.
- Tokens: retheme with the `--lumen-*` custom properties (`--lumen-accent`, `--lumen-accent-foreground`, `--lumen-accent-text`, `--lumen-bad`, `--lumen-bad-text`, `--lumen-chart-accent`, `--lumen-chart-accent-foreground`, `--lumen-chart-accent-text`, `--lumen-focus`, `--lumen-good`, `--lumen-good-text`, `--lumen-hairline`, `--lumen-ink`, `--lumen-muted-ink`, `--lumen-series-1`, `--lumen-series-2`, `--lumen-series-3`, `--lumen-series-4`, `--lumen-series-5`, `--lumen-series-6`, `--lumen-warn`, `--lumen-warn-text`); this item's CSS also reads `--lumen-font-sans`, `--lumen-radius-k`. Never add Tailwind colour classes inside the component.

```tsx
import { InlineEdit } from "@/components/ui/lumen/controls/inline-edit";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `InlineEdit` | — | The wrapper; inherits the font around it. |
| `(text)` | — | The text as a button. |
| `(field)` | — | The field while editing. |
| `(reason)` | — | Why a value was refused. |

## Sound
- Keep every `data-slot` and `data-sound` attribute: the sound layer reads them.
- Installing this item adds no audio. Nothing plays until the app mounts `GlassSoundProvider` once (install: `npx shadcn@latest add https://beautiful-ui.dev/r/glass-sound.json`, import from `@/components/beautiful-ui/glass-sound`); `GlassSoundToggle` is its mute control. Without a provider the audio engine never loads.

## Match the original
- Read `components/ui/lumen/controls/inline-edit.tsx` as the reference implementation before changing or recreating anything, and match it: sizes, colours per theme, motion timings, copy and behaviour.
- If you deviate (a prop you can't honour, a style you changed, a dependency you swapped), say so in your reply, part by part.
- Keep the accessibility contract, the keyboard map and the motion levels listed below.

## Use it when
- inline edit, rename in place, editable text, editable title, click to edit, contenteditable, rename
- Renaming things where they're shown: a project title, a file, a board column, a table row's name
- One short value people change now and then

### Not when
- Several fields at once: use a form with a Save button
- Long text: use Textarea

## Mistakes
- Always pass aria-label: the visible text is the value, not a label
- Return the save's promise from onValueChange so a failure rolls back

## Usage

```tsx
"use client";

import { InlineEdit } from "@/components/ui/lumen/controls/inline-edit";

export function ProjectTitle({ id, name }: { id: string; name: string }) {
  return (
    <h1 className="text-2xl font-semibold">
      <InlineEdit
        aria-label="Project name"
        defaultValue={name}
        maxLength={60}
        validate={(v) => (v.length < 3 ? "Use at least 3 characters" : null)}
        onValueChange={async (next) => {
          const res = await fetch(`/api/projects/${id}`, { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ name: next }) });
          // Throwing (or rejecting) puts the old name back and says the save failed.
          if (!res.ok) throw new Error("Couldn't rename");
        }}
      />
    </h1>
  );
}
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `aria-label` | `string` |  | Names the field ("Project name"). Required: the text alone doesn't say what it is. |
| `value / defaultValue` | `string` |  | Controlled or uncontrolled text. |
| `onValueChange` | `(value: string) => void \| Promise<unknown>` |  | Called with the saved text. Return a promise: a rejection restores the old text and announces it. |
| `validate` | `(value: string) => string \| null` |  | Return a reason to refuse a value; the field stays open and shows it. |
| `placeholder` | `string` | `"Untitled"` | Shown when the text is empty. |
| `allowEmpty` | `boolean` | `false` | Save an empty value instead of keeping the old one. |
| `saveOnBlur` | `boolean` | `true` | Leaving the field saves; false makes it revert. |
| `editing / onEditingChange` | `boolean / (editing) => void` |  | Controlled edit mode, e.g. to open it from a Rename menu item. |
| `maxLength / disabled` | `number / boolean` |  | As on an input. |
| `labels` | `Partial<{ edit, failed }>` |  | The words, for other languages. |

Full docs: https://beautiful-ui.dev/components/lumen-inline-edit

## Customising
- Colours: set the `--lumen-*` tokens on `:root`, or on a container with the `lumen-scope` class to retheme one area. Add the `lumen-inherit` class to follow your shadcn palette instead (`--chart-N`, `--destructive`).
- Dark mode follows the `.dark` class on an ancestor (the shadcn and next-themes convention).
- Update later by re-running the install with `--overwrite` (review the diff if you edited it). Changelog: https://beautiful-ui.dev/r/changelog.json

## Keyboard

| Keys | Action |
|---|---|
| Enter, Space or F2 | Edit (on the text) |
| Enter | Save |
| Escape | Put the old text back |
| Tab | Save (or revert with saveOnBlur={false}) and move on |

## Motion inventory

| Interaction | What moves |
|---|---|
| Hover | A hairline box and a pen appear; the field opens in the same box with no movement |

## Accessibility contract (preserve when editing)
- The text is a button named "Project name: Q4 launch. Rename"; the field carries the same name
- A refused value is aria-invalid with the reason linked and announced; a failed save is announced
- Focus returns to the text after Enter or Escape

## Install

```bash
npx shadcn@latest add @beautiful-ui-pro/lumen-inline-edit
```

Pro item: needs the `@beautiful-ui-pro` registry in `components.json` and `BEAUTIFUL_UI_TOKEN` in `.env.local` (https://beautiful-ui.dev/account). Setup: https://beautiful-ui.dev/docs/pro. Your components.json `style` picks the build: radix-*, new-york and default get Radix, base-* gets Base UI.

## Credits
- Built on shadcn/ui (https://ui.shadcn.com)

The lumen foundation (the tokens listed above, keyframes and motion levels) installs once with the first component; its CSS is public at https://beautiful-ui.dev/r/lumen-foundation.json.
