Back to Shark UI

Editable

docs/components/editable

latest10.4 KB
Original Source

Sections

Components

Utilities

Forms

Hooks

Editable

Copy Markdown

Allows user to edit text in-place.

DocsAPI

PreviewCode

Edit user

Click in the field or edit button to start editing

Name

Vinicius Vicentini

Username

@vinihvc

Installation#

CLIManual

pnpmbunnpmyarn

pnpm dlx shadcn@latest add @shark/editable

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.

PreviewCode

Edit user

Click the edit button to start editing

Edit

Name

Vinicius Vicentini

Username

@vinihvc

Modes#

The activationMode prop controls how editing is triggered.

Focus#

Editing starts when the field receives focus.

PreviewCode

Edit with focus

Focus the field to start editing (default activation mode)

Name

Vinicius Vicentini

Username

@vinihvc

Click#

Editing starts with a single click on the preview.

PreviewCode

Edit with click

Click the text to start editing

Name

Vinicius Vicentini

Username

@vinihvc

Double-Click#

Editing starts with a double-click on the preview.

PreviewCode

Edit with double-click

Double-click the text to start editing

Name

Vinicius Vicentini

Username

@vinihvc

None#

No automatic activation. Use EditableEditTrigger to manually start editing.

PreviewCode

Edit with manual trigger

Use the edit button to start editing (no automatic activation)

Name

Vinicius Vicentini

Username

@vinihvc

Sizes#

The size prop on EditablePreview controls the preview dimensions.

Small#

PreviewCode

Editable content

Large#

PreviewCode

Editable content

Orientation#

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

Horizontal#

PreviewCode

Editable content

Vertical#

PreviewCode

Editable contentEditable content

Examples#

With Textarea#

PreviewCode

Edit description

Double-click the text to start editing

Description

This is a longer description that can be edited. Click to edit and make changes.This is a longer description that can be edited. Click to edit and make changes.

Without Controls#

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

PreviewCode

Edit without controls

Click the field to edit, press Enter to save, Escape to cancel

Name

Vinicius Vicentini

Email

[email protected]

API Reference#

Editable#

Root component. Manages edit mode and value.

PropTypeDefault
activationMode`focusdblclick
orientation`"horizontal""vertical"`
submitMode`bothenter
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"
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.

[

Previous page

Drawer ](/docs/components/drawer)[

Next page

Field ](/docs/components/field)

On This Page

InstallationAnatomyUsageControlledModesFocusClickDouble-ClickNoneSizesSmallLargeOrientationHorizontalVerticalExamplesWith TextareaWithout ControlsAPI ReferenceEditableEditableAreaEditableInputEditablePreviewEditableControlEditableEditTriggerEditableCancelTriggerEditableSubmitTrigger