Skip to content
Theme:

Ui3nEditable ​

Inline editable text component. Click on the text to enter edit mode, press Enter or click the checkmark to confirm, press Escape or click the cross to cancel.

Props

NameTypeDefaultDescription
idstring | undefined —

Root element id

namestring | undefined —

HTML name attribute for form submission

modelValue*string —

Current value of the editable content

placeholderstring | undefined —

Placeholder text

maxLengthnumber | undefined —

Maximum length of the text

maxWidthstring | number | undefined —

Maximum width of the component

tooltipWidthnumber | undefined —

Tooltip width

disabledboolean | undefined —

Component disabled flag

selectAllOnFocusboolean | undefined —

Flag for automatic selection of all text on focus

disallowEmptyValueboolean | undefined —

Flag to prevent empty values

validator((value: string) => string | true) | undefined —

Check of a changed value on completion: returns true to accept it, or the error text to reject it. A rejected value is reverted to the initial one and the `invalid` event is emitted instead of `update:modelValue`

Events

Event NameArguments / Value TypeDescription
update:modelValuevalue: string —
done —
cancel —
focusinvalue: FocusEvent —
focusout —
toggle:editModevalue: boolean —
invaliderror: string, value: string —

Public Methods & Exposes

Method NameSignature / TypeDescription
clear()() => void

Clears the value

reset()() => void

Shows the current modelValue again and leaves the edit mode; for a rejection known later, e.g. a failed save

CSS Variables

Set any of these where you need it — on :root, on a container, or on the element itself through [data-ui3n] — and the component follows. Leave them alone and it uses the defaults below.

NameDefault
--ui3n-editable-border-radius4px
--ui3n-editable-button-hover-bg-colorvar(--color-bg-button-secondary-hover)
--ui3n-editable-button-size16px
--ui3n-editable-edit-bg-colorvar(--color-bg-control-primary-default, #fff)
--ui3n-editable-edit-border-colorvar(--color-border-table-accent-default)
--ui3n-editable-edit-border-warning-colorvar(--error-content-default)
--ui3n-editable-empty-colorvar(--color-text-table-secondary-default)
--ui3n-editable-font-size12px
--ui3n-editable-height24px
--ui3n-editable-hover-bg-colorvar(--color-bg-control-primary-hover)
--ui3n-editable-max-width100%
--ui3n-editable-min-width60px
--ui3n-editable-placeholder-colorvar(--color-text-table-secondary-default)
--ui3n-editable-text-colorvar(--color-text-table-primary-default)

Usage Examples ​

Basic usage ​

Basic usage

Click on the text to enter edit mode. Press Enter to confirm or Escape to cancel.

Editable text
Current value: Editable text

Disallow empty value ​

Disallow empty value

Using disallowEmptyValue prop prevents saving an empty value. The input border turns red when the value is empty.

Required field
This field cannot be empty (disallowEmptyValue)

Disabled state ​

Disabled state

Disabled component does not allow entering edit mode.

Disabled field
Disabled state — editing is not available

Validation and reverting a rejected value ​

Validation and reverting a rejected value

The validator prop checks a changed value on completion. A rejected value is reverted and the invalid event is emitted instead of update:modelValue. When a value is rejected later (e.g. saving fails), call the exposed reset() to show the current modelValue again.

report.pdf
Try "..", "a/b" (rejected by the validator) or a name starting with "locked" (rejected after saving)