Skip to content
Haze UI

Inline edit

Switch a label or description into an editable field in place, with explicit save, cancel and retry states.

pnpm dlx shadcn@latest add @haze/inline-edit
Open preview in a new tab
Livesmall script

When to use

  • A project title or short description is read often and edited occasionally.
  • A settings row needs its own save action and feedback.

When not to use

  • Several fields in the same form are reviewed and saved together. Use input or textarea.

Installation

Add the Haze registry to components.json once, then install Inline edit with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/inline-edit
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Unique control ID and prefix for the read button, label and feedback.
namestringidName submitted to a native form.
labelstringNameVisible label used when editing and in action names.
valuestring""Initially committed text.
placeholderstringAdd a valueVisible hint when the value is empty.
multilinebooleanfalseUse a growing native textarea. Shift+Enter inserts a line break.
variant"title" | "body"bodyTypography shared by the resting text and the field.
required / disabled / readonlyboolean–Native validation and editing states.
classstring–Extra classes on the root.
...attributesHTML form control attributes–Forwarded to the input or textarea, including form, maxlength and aria-describedby.

Keyboard interactions

EnterSpace
Open the editor from the value button.
EnterEscape
Apply the draft or cancel it and restore the saved value.
ShiftEnter
Insert a line break in a multiline value.
Tab
Move through save and cancel. Leaving the whole editor commits a valid draft.

Accessibility

  • A native button names the field and its value. Save and cancel return keyboard focus to that button.
  • Errors and save results use a live region. Without JavaScript the editor is an ordinary labelled form control.
  • Changes apply locally. A bubbling haze:inline-edit-save event provides detail.value and detail.previousValue. Call detail.waitUntil(promise) during dispatch to show pending progress and restore the previous value on rejection. Reopening offers the failed draft for retry.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Inline edit" with `npx shadcn@latest add @haze/inline-edit`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import InlineEdit from "@/components/haze/ui/inline-edit.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/inline-edit.md

  • Customize with real content

    Adapt the Haze inline-edit ui for our product. Replace the demo values of these props with our real content: id, name, label, value, placeholder, multiline, variant, required / disabled / readonly, class, ...attributes. Keep the layout, the heading level rules and these accessibility details: A native button names the field and its value. Save and cancel return keyboard focus to that button. Errors and save results use a live region. Without JavaScript the editor is an ordinary labelled form control. Changes apply locally. A bubbling haze:inline-edit-save event provides detail.value and detail.previousValue. Call detail.waitUntil(promise) during dispatch to show pending progress and restore the previous value on rejection. Reopening offers the failed draft for retry. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using inline-edit, check it fits: use it when a project title or short description is read often and edited occasionally.; a settings row needs its own save action and feedback.. Avoid it when several fields in the same form are reviewed and saved together. use input or textarea.. Alternatives: @haze/input, @haze/textarea, @haze/field.

Dependencies

  • npm: @lucide/astro
  • @haze/button
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog