structyl

Editable API

View component

The full prop reference for the Editable component. Inline-editable text that swaps between preview and input.

Import

tsx
import { Editable } from '@structyl/styled';

Props

Root

The root container for the editable component that manages state and provides context to its children.

PropTypeDefault
value#string

Controlled value of the editable input

defaultValue#string

Initial value when uncontrolled

''
onValueChange#(value: string) => void

Callback fired when the input value changes

editing#boolean

Controlled editing state

defaultEditing#boolean

Initial editing state when uncontrolled

false
onEditingChange#(editing: boolean) => void

Callback fired when editing state changes

submitMode#'enter' | 'blur' | 'both'

Determines when input submission occurs (Enter key, blur event, or both)

'both'
onSubmit#(value: string) => void

Callback fired when the input value is submitted

onCancel#() => void

Callback fired when editing is cancelled (Escape key)

disabled#boolean

Disables editing and prevents preview from entering edit mode

asChild#boolean

If true, renders as a child element instead of a div

className#string

CSS class name applied to the root element

Preview

The display element showing the current value; clicking it enters edit mode.

PropTypeDefault
children#React.ReactNode

Placeholder text displayed when the value is empty

className#string

CSS class name applied to the preview element

onClick#(event: React.MouseEvent<HTMLSpanElement>) => void

Custom click handler (composed with built-in enter-edit handler)

onKeyDown#(event: React.KeyboardEvent<HTMLSpanElement>) => void

Custom keydown handler (composed with built-in Enter/Space handler)

Input

The text input element that appears during edit mode.

PropTypeDefault
className#string

CSS class name applied to the input element

placeholder#string

Placeholder text shown when the input is empty

onChange#(event: React.ChangeEvent<HTMLInputElement>) => void

Custom change handler (composed with built-in value tracking)

onKeyDown#(event: React.KeyboardEvent<HTMLInputElement>) => void

Custom keydown handler (composed with submit/cancel handlers)

onBlur#(event: React.FocusEvent<HTMLInputElement>) => void

Custom blur handler (composed with built-in submit handler)

Source code

If you didn't find what you need here, read the component implementation .

structyl — Accessible React Component Library