---
title: "Editable"
description: "Text that turns into a field when you press it, such as a page title or a table cell. Enter or a click outside saves it, and Escape undoes it."
url: https://gelatinui.com/components/editable
markdown_url: https://gelatinui.com/components/editable.md
access: free
install: "npx shadcn@latest add @gelatin-ui/editable"
registry_item: https://gelatinui.com/r/editable.json
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Editable

> Text that turns into a field when you press it, such as a page title or a table cell. Enter or a click outside saves it, and Escape undoes it.

Page: https://gelatinui.com/components/editable

## When to use it

Best for: Text that people read most of the time and change now and then, with no form around it.

- Use it for a title, a name in a list, or a table cell that people rename.
- Use `onSubmit` with a promise to save to a server: it shows a spinner and the error.
- Use `multiline` with `EditableTextarea` for many lines.

## When not to use it

- For a field that people always fill in, use an [Input](https://gelatinui.com/components/input.md).
- For many fields that save together, use a [Form](https://gelatinui.com/components/form.md).

## Notes for agents

- Put `EditablePreview` and `EditableInput` (or `EditableTextarea`) in `EditableArea`. Give the field an `aria-label`.
- `activationMode` is `click` (default), `dblclick`, `focus`, or `none`. `submitMode` is `both` (default), `enter`, `blur`, or `none`.
- `onSubmit` may return a promise. A reject keeps the field open and shows its message in `EditableError`.
- An empty text cancels unless `allowEmpty` is set.
- Text classes on the root size both the preview and the field.
- `EditableControls` holds the optional `EditableEditTrigger`, `EditableSubmitTrigger`, and `EditableCancelTrigger`.

## Anatomy

```text
Editable
├─ EditableArea (0..n)
├─ EditablePreview (0..n)
├─ EditableInput (0..n)
├─ EditableTextarea (0..n)
├─ EditableControls (0..n)
├─ EditableEditTrigger (0..n)
├─ EditableSubmitTrigger (0..n)
├─ EditableCancelTrigger (0..n)
└─ EditableError (0..n)
```

## API reference

### Editable

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string` |  | The saved text (controlled). |
| `defaultValue` | `string` | "" | The saved text at mount. |
| `onValueChange` | `function` |  | Called with the new text after a save (after `onSubmit` resolves). |
| `onSubmit` | `function` |  | Called on a save with the new text. Return a Promise for an async save: the field turns read-only and the Submit trigger spins; a reject keeps the field open with its message. |
| `onCancel` | `function` |  | Called when an edit ends with no save (Escape, Cancel, or an empty text). |
| `editing` | `boolean` |  | Shows the field (controlled). |
| `defaultEditing` | `boolean` | false | Shows the field at mount (a rename started from a menu). |
| `onEditingChange` | `function` |  |  |
| `activationMode` | `EditableActivationMode` | "click" | What opens the field: `click` (default; Enter, Space, or F2 on the focused preview too), `dblclick` (a list where a click selects; Enter and F2 still open it), `focus`, or `none` (only `editing` and the Edit trigger). |
| `submitMode` | `EditableSubmitMode` | "both" | What saves: `both` (default: Enter and a blur), `enter`, `blur`, or `none`. A blur that does not save cancels. |
| `selectOnFocus` | `boolean` | true | Selects the text when the field opens. Default `true`; else the caret goes to the end. |
| `multiline` | `boolean` | false | Many lines: Enter adds a line, Mod+Enter saves. Use `EditableTextarea`. |
| `placeholder` | `string` |  | The muted text of the preview when the text is empty. |
| `disabled` | `boolean` | false |  |
| `readOnly` | `boolean` | false | No edit; the text stays selectable. |
| `invalid` | `boolean` | false | The field shows the error look, and Enter and a blur do not save. |
| `allowEmpty` | `boolean` | false | Save an empty text. Default `false`: an empty text cancels. |
| `size` | `"default" \| "lg" \| "sm"` | "default" |  |
| `variant` | `"ghost" \| "outline"` | "ghost" | `ghost` (default): text with no edge at rest. `outline`: the field edge at rest, for a form. |
| `rounded` | `"default" \| "full"` | "default" |  |
| `width` | `"fill" \| "fit"` | multiline ? "fill" : "fit" | `fit`: as wide as the text (default for one line). `fill`: the full row (default for many). |
| `labels` | `Partial<EditableLabels>` |  |  |

### EditableArea

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `indicator` | `boolean` | true | The pencil hint after the box: a 24px slot that is always there, so the box keeps its place when the pencil fades in on hover or focus. No pencil on a touch screen. Default `true`; turn it off with the Edit trigger or in a table cell. |

### EditablePreview

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `ReactNode` |  | Custom text in the preview. Default: the saved text, or the placeholder. |

### EditableInput

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### EditableTextarea

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### EditableControls

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### EditableEditTrigger

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `busy` | `boolean` |  | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `spinnerPlacement` | `"center" \| "start"` |  | `center` (default): the spinner covers the label. `start`: it takes the leading icon slot. The icon sizes always use `center`, because their one icon is the label. |
| `glass` | `"clear" \| "dark" \| "light"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` |  |  |
| `children` | `ReactNode` |  |  |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

### EditableSubmitTrigger

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `busy` | `boolean` |  | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `spinnerPlacement` | `"center" \| "start"` |  | `center` (default): the spinner covers the label. `start`: it takes the leading icon slot. The icon sizes always use `center`, because their one icon is the label. |
| `glass` | `"clear" \| "dark" \| "light"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` |  |  |
| `children` | `ReactNode` |  |  |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

### EditableCancelTrigger

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `busy` | `boolean` |  | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `spinnerPlacement` | `"center" \| "start"` |  | `center` (default): the spinner covers the label. `start`: it takes the leading icon slot. The icon sizes always use `center`, because their one icon is the label. |
| `glass` | `"clear" \| "dark" \| "light"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` |  |  |
| `children` | `ReactNode` |  |  |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

### EditableError

No props of its own: `className`, `children`, and every other prop go to the element it renders.

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Editable | `editable` | `data-disabled` |  |  |
| EditableArea | `editable-area` | `data-editing`, `data-stage-focused` | `--editable-indicator`, `--radius` | `motion-timing` |
| EditablePreview | `editable-preview` | `data-editing`, `data-placeholder` | `--radius` | `motion-timing` |
| EditableInput | `editable-input` |  | `--radius` |  |
| EditableTextarea | `editable-textarea` |  | `--radius` |  |
| EditableControls | `editable-controls` |  |  | `hit-area` |
| EditableEditTrigger | `editable-edit-trigger` |  |  | `motion-timing` |
| EditableSubmitTrigger | `editable-submit-trigger` |  |  | `motion-timing` |
| EditableCancelTrigger | `editable-cancel-trigger` |  |  | `motion-timing` |
| EditableError | `editable-error` |  |  |  |

## Usage

Wrap a preview and an input in an area. A press, Enter, or a double click opens the field; Enter or a blur saves, Escape cancels.

```tsx title="report-title.tsx"
import { Editable, EditableArea, EditableInput, EditablePreview } from "@/components/ui/editable";

export function ReportTitle() {
  return (
    <Editable defaultValue="Q4 report" onValueChange={(name) => console.log(name)}>
      <EditableArea>
        <EditablePreview />
        <EditableInput aria-label="Report name" />
      </EditableArea>
    </Editable>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/editable
```

It adds 24 registry items: 21 files, 3700 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `@xstate/react`, `clsx`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## Built on

- [Button](https://gelatinui.com/components/button.md)
- [Input](https://gelatinui.com/components/input.md)
- [Textarea](https://gelatinui.com/components/textarea.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Input](https://gelatinui.com/components/input.md)
- [Textarea](https://gelatinui.com/components/textarea.md)
- [Field](https://gelatinui.com/components/field.md)
- [Form](https://gelatinui.com/components/form.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Enter, Space, F2 | On the preview: opens the field with the text selected. |
| Enter | In the field: saves. With `multiline`, adds a line. |
| Mod + Enter | With `multiline`: saves. |
| Escape | Puts the old text back and closes the field. |

## Motion

| Part | Motion |
| --- | --- |
| Swap | none · the preview and the field share one box, so nothing moves |
| Hover | hover · the preview tints and the pencil fades in |
