diff --git a/packages/core/src/components/editable-text/editable-text.md b/packages/core/src/components/editable-text/editable-text.md index 1f593bd14f..3cadb0ab39 100644 --- a/packages/core/src/components/editable-text/editable-text.md +++ b/packages/core/src/components/editable-text/editable-text.md @@ -1,18 +1,35 @@ @# Editable text -__EditableText__ is an interactive component which appears as normal UI text. It transforms into an interactive -text input field when a user hovers and/or focuses on it. +**EditableText** is an interactive component that displays as static text but +visually resembles an input field on hover. When clicked or focused, +it transforms into a text input, allowing for inline text editing. -The text input inherits all font styling from its ancestors, making for a seamless transition between reading and -editing text. +The text input inherits font styling from its parent elements, making for a +seamless transition between reading and editing text. **EditableText** is ideal +for inline renaming, editable descriptions, or simple text updates. You should +not use **EditableText** when a more static, always-editable [**InputGroup**](#core/components/input-group) +or [**TextArea**](#core/components/text-area) component would suffice. -You might use this component for inline renaming, or for an -[editable multiline description](#core/components/editable-text.multiline-mode). -You should not use __EditableText__ when a more static, always-editable -[__InputGroup__](#core/components/input-group) or [__TextArea__](#core/components/text-area) -component would suffice. +@## Import -@reactExample EditableTextExample +```tsx +import { EditableText } from "@blueprintjs/core"; +``` + +@## Usage + +**EditableText** can be used in both controlled and uncontrolled modes, similar +to a standard React [`` element](https://react.dev/reference/react-dom/components/input). +Use the `value` prop for controlled usage, and `defaultValue` for uncontrolled usage. Use `onChange` to listen to +ongoing updates and use `onConfirm` and `onCancel` to listen only to completed or canceled edits. + +The `onConfirm` callback is invoked when a user presses Enter +(or Mod + Enter when multiline) or when the user blurs the input. +The `onCancel` callback is invoked when user presses Escape. +Canceling resets the field to the last confirmed value. Neither callback is +invoked if the value is unchanged. + +@reactCodeExample EditableTextBasicExample
Centering EditableText
@@ -23,34 +40,40 @@ you should center the component via flexbox or with `position` and `transform: t
- @## Multiline mode -By default, __EditableText__ supports _exactly one line of text_ and will grow or shrink horizontally based on the -length of text. - -You may enable the `multiline` prop to use a `