Skip to content
shadcn.io
shadcn.io is not affiliated with official shadcn/ui

Shadcn Editable for React and Tailwind

Allows user to edit text in-place.

Edit user

Click in the field or edit button to start editing

Vinicius Vicentini
@vinihvc

Installation

bunx --bun shadcn@latest add https://kit.dev/r/editable.json

Anatomy

Editable
├── EditableArea
│   ├── EditablePreview
│   └── EditableInput
└── EditableControl
    ├── EditableEditTrigger
    ├── EditableCancelTrigger
    └── EditableSubmitTrigger

Usage

import { 
  Editable,
  EditableArea,
  EditableInput,
  EditablePreview,
  EditableControl,
  EditableCancelTrigger,
  EditableSubmitTrigger,
  EditableEditTrigger,
} from "@/components/ui/editable";
<Editable>
  <EditableArea>
    <EditableInput />
    <EditablePreview />
  </EditableArea>
  <EditableControl>
    <EditableCancelTrigger/>
    <EditableSubmitTrigger/>
    <EditableEditTrigger/>
  </EditableControl>
</Editable>

Controlled

Make the entire form editable at once by using the edit prop.

The value and onValueChange props control the editable component programmatically.

Modes

The activationMode prop controls how editing is triggered.

Focus

Editing starts when the field receives focus.

Click

Editing starts with a single click on the preview.

Double-Click

Editing starts with a double-click on the preview.

None

No automatic activation. Use EditableEditTrigger to manually start editing.

Sizes

The size prop on EditablePreview controls the preview dimensions.

Small

Large

Orientation

The orientation prop controls the layout of the editable component and its controls.

Horizontal

Vertical

Examples

With Textarea

Without Controls

Edit without control buttons. Press Enter to save, Escape to cancel.

API Reference

Editable

Root component. Manages edit mode and value.

PropTypeDefault
activationModefocus | dblclick | click | none'focus'
orientation"horizontal" | "vertical""horizontal"
submitModeboth | enter | blur | none'both'
asChildboolean-
classNamestring-

EditableArea

Wraps the input and preview views.

PropTypeDefault
asChildboolean-
classNamestring-

EditableInput

Input shown when editing. Use asChild for custom input elements.

PropTypeDefault
asChildboolean-
classNamestring-

EditablePreview

Shows the value when not editing. Click to enter edit mode.

PropTypeDefault
asChildboolean-
size"xs" | "sm" | "md" | "lg" | "xl""md"
classNamestring-

EditableControl

Holds edit/cancel/submit control buttons.

PropTypeDefault
asChildboolean-
classNamestring-

EditableEditTrigger

Enters edit mode on click.

PropTypeDefault
asChildboolean-
classNamestring-

EditableCancelTrigger

Cancels editing and reverts to previous value.

PropTypeDefault
asChildboolean-
classNamestring-

EditableSubmitTrigger

Submits the edited value and exits edit mode.

PropTypeDefault
asChildboolean-
classNamestring-

For a complete list of props, see the Ark UI documentation.