Skip to Content
Documentation
Saas UI
Get Pro
Getting started
Components
Overview

Editable

Used for inline renaming of some text.

SourceStorybookRecipeArk
Click to edit

Anatomy

import { Editable } from '@saas-ui/react/editable'
<Editable.Root>
  <Editable.Preview />
  <Editable.Input />
</Editable.Root>

Examples

Controlled

Click to edit

With Double Click

Use the activationMode prop to make the content editable when users double click.

Double click to edit

Disabled

Use the disabled prop to disable the editable component.

Click to edit

TextArea

You can make a text area editable.

Click to edit

With Controls

Add controls such as "edit", "cancel" and "submit" to Editable for better user experience.

Click to edit

Props

Root

PropDefaultType
activationMode '\'focus\''
ActivationMode

The activation mode for the preview element. - "focus" - Enter edit mode when the preview is focused - "dblclick" - Enter edit mode when the preview is double-clicked - "click" - Enter edit mode when the preview is clicked

selectOnFocus true
boolean

Whether to select the text in the input when it is focused.

submitMode '\'both\''
SubmitMode

The action that triggers submit in the edit mode: - "enter" - Trigger submit when the enter key is pressed - "blur" - Trigger submit when the editable is blurred - "none" - No action will trigger submit. You need to use the submit button - "both" - Pressing `Enter` and blurring the input will trigger submit

colorPalette 'gray'
'gray' | 'zinc' | 'neutral' | 'stone' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'presence' | 'status' | 'sidebar' | 'sidebar.accent' | 'accent' | 'slate'

The color palette of the component

size 'md'
'sm' | 'md' | 'lg'

The size of the component

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
autoResize
boolean

Whether the editable should auto-resize to fit the content.

defaultEdit
boolean

Whether the editable is in edit mode by default.

defaultValue
string

The initial value of the editable when rendered. Use when you don't need to control the value of the editable.

disabled
boolean

Whether the editable is disabled.

edit
boolean

Whether the editable is in edit mode.

finalFocusEl
() => HTMLElement | null

The element to receive focus when the editable is closed.

form
string

The associate form of the underlying input.

id
string

The unique identifier of the machine.

ids
Partial<{ root: string area: string label: string preview: string input: string control: string submitTrigger: string cancelTrigger: string editTrigger: string }>

The ids of the elements in the editable. Useful for composition.

invalid
boolean

Whether the input's value is invalid.

maxLength
number

The maximum number of characters allowed in the editable

name
string

The name attribute of the editable component. Used for form submission.

onEditChange
(details: EditChangeDetails) => void

Function to call when the edit mode changes.

onFocusOutside
(event: FocusOutsideEvent) => void

Function called when the focus is moved outside the component

onInteractOutside
(event: InteractOutsideEvent) => void

Function called when an interaction happens outside the component

onPointerDownOutside
(event: PointerDownOutsideEvent) => void

Function called when the pointer is pressed down outside the component

onValueChange
(details: ValueChangeDetails) => void

Function to call when the value changes.

onValueCommit
(details: ValueChangeDetails) => void

Function to call when the value is committed.

onValueRevert
(details: ValueChangeDetails) => void

Function to call when the value is reverted.

placeholder
string | { edit: string; preview: string }

The placeholder text for the editable.

readOnly
boolean

Whether the editable is read-only.

required
boolean

Whether the editable is required.

translations
IntlTranslations

The translations for the editable.

value
string

The controlled value of the editable.

Previous

Drawer

Next

Empty State