Editable Label

A label that switches to an inline text input when clicked. Committing (Enter or blur) updates the bindable value and fires onEdit; Escape cancels. Render as any heading level or a span via as.

Usage

<script>
  import { EditableLabel } from '@vultra/ui';

  let title = $state('My Project');
</script>

<EditableLabel bind:value={title} as="h2" onEdit={(v) => console.log('Renamed to', v)} />

Props

PropTypeDefaultDescription
valuestringBindable label text
placeholderstring'Click to edit'Placeholder when empty
as'h1' \| 'h2' \| 'h3' \| 'h4' \| 'h5' \| 'h6' \| 'span' \| 'p''span'Element rendered while not editing
onEdit(value: string) => voidCalled when a change is committed
maxLengthnumberMax input length while editing
classstringAdditional CSS classes

Features

  • Click to edit, Enter/blur to commit, Escape to cancel.
  • Automatically focuses and selects the input when editing starts.
  • Heading elements get token-based typography sizes.
  • Empty commits revert to the previous value.