Documentation

InlineRename

An anchored name editor with async saving, validation and focus restoration. The input overlays its anchor without nesting inside a button or changing the surrounding layout.

Click the name to edit. Try “Taken” to see validation, or press Escape to cancel.

Props

PropTypeDefaultDescription
anchorHTMLElement | nullRequiredElement to cover; null renders nothing
initialValuestringRequiredName selected when the editor opens
labelstringRequiredAccessible input label
onSave(name: string) => void | Promise<void>RequiredSave the trimmed name; throw/reject to show an error
onClose() => voidRequiredRemove the editor
saveOnBlurbooleantrueSave on blur; false discards instead
sizeSize"small"Text size; match the anchor label
maxLengthnumber256Maximum input length
jssJSS—Overlay styles

Behavior

  • Enter saves; Escape cancels. IME composition does neither.
  • Empty or unchanged names close without calling onSave.
  • Pending saves make the input read-only and prevent duplicate submission or cancellation.
  • Errors keep the editor open and are announced. Editing clears the error.
  • Keyboard completion restores anchor focus; blur and async completion do not steal focus from another control.
  • Position follows scrolling and resizing, with viewport clamping. Native popovers escape clipping where supported; fixed positioning is the fallback.
  • No browser globals are accessed during server rendering. Open it from an interaction and unmount it on close.
const [name, setName] = useState("My project");
const [anchor, setAnchor] = useState<HTMLElement | null>(null);

<>
  <Button
    size="small"
    color="secondary"
    onClick={(event) => setAnchor(event.currentTarget)}
  >
    {name}
  </Button>
  {anchor && (
    <InlineRename
      anchor={anchor}
      initialValue={name}
      label="Project name"
      onSave={setName}
      onClose={() => setAnchor(null)}
    />
  )}
</>;

For document tabs, use the per-tab onRename callback on Tabs.