Skip to content
HyperUX Experimental
Demo

Website-style Edit profile section with multiple inline editors. Each row supports focus trapping while active, Enter to save, and Escape to cancel.

Edit profile

Update the public details shown on your profile page.

Changes save instantly in this demo

Display name

Headline

Location

Website

Username

Pronouns


Alpine.js Inline Editor

huxInlineEditor manages the behavior switch between static display and inline editing. It keeps committed input state, supports commit/revert keyboard shortcuts, and traps focus within the active editor controls.

Runtime Constraints

API

huxInlineEditor(config)

Returns an Alpine data object with:

Internal helper methods are private implementation details and are not part of the supported API contract.

Options

Quick Start

<div x-data="huxInlineEditor({ inputValue: 'Ada Lovelace' })">
  <div x-show="!isEditing" x-cloak x-transition.opacity>
    <span x-text="inputValue"></span>
    <button type="button" x-on:click="enterEditMode()">Edit</button>
  </div>

  <div
    x-show="isEditing"
    x-cloak
    x-transition.opacity
    x-ref="inlineEditor"
    x-on:keydown="trapFocus($event)"
  >
    <label>
      <span class="sr-only">Profile name</span>
      <input
        x-ref="inlineEditorInput"
        x-model="draftValue"
        type="text"
        x-init="registerInput($el)"
        aria-describedby="profile-name-inline-editor-help"
        x-on:focus="handleInputFocus($event)"
        x-on:keydown="handleInputKeydown($event)"
      />
    </label>
    <button type="button" x-on:click="commitChanges()">Save</button>
    <button type="button" x-on:click="revertChanges()">Cancel</button>
  </div>

  <p id="profile-name-inline-editor-help">
    Press Enter to save, Escape to cancel, and Tab to cycle within editor controls.
  </p>
</div>

Common Usage Patterns

Listen for commit events

<div
  x-data="huxInlineEditor({ editorId: 'profile-name', inputValue: 'Ada Lovelace' })"
  x-on:hux-inline-editor:profile-name:commit.window="console.log($event.detail.inputValue)"
>
  ...
</div>

Configure an explicit return-focus target

<div x-data="huxInlineEditor({ inputValue: 'Ada Lovelace', returnFocusTemplateRef: 'editButton' })">
  <button type="button" x-ref="editButton" x-on:click="enterEditMode()">Edit</button>
  ...
</div>

Commit and revert with keyboard

<input
  x-ref="inlineEditorInput"
  x-model="draftValue"
  type="text"
  x-init="registerInput($el)"
  aria-describedby="profile-name-inline-editor-help"
  x-on:focus="handleInputFocus($event)"
  x-on:keydown="handleInputKeydown($event)"
/>

Behavior Contract

Error Handling

Accessibility Notes

Notes