Editable API
View componentThe full prop reference for the Editable component. Inline-editable text that swaps between preview and input.
Import
import { Editable } from '@structyl/styled';Props
Root
The root container for the editable component that manages state and provides context to its children.
| Prop | Type | Default |
|---|---|---|
| value# | stringControlled value of the editable input | — |
| defaultValue# | stringInitial value when uncontrolled | '' |
| onValueChange# | (value: string) => voidCallback fired when the input value changes | — |
| editing# | booleanControlled editing state | — |
| defaultEditing# | booleanInitial editing state when uncontrolled | false |
| onEditingChange# | (editing: boolean) => voidCallback fired when editing state changes | — |
| submitMode# | 'enter' | 'blur' | 'both'Determines when input submission occurs (Enter key, blur event, or both) | 'both' |
| onSubmit# | (value: string) => voidCallback fired when the input value is submitted | — |
| onCancel# | () => voidCallback fired when editing is cancelled (Escape key) | — |
| disabled# | booleanDisables editing and prevents preview from entering edit mode | — |
| asChild# | booleanIf true, renders as a child element instead of a div | — |
| className# | stringCSS class name applied to the root element | — |
Preview
The display element showing the current value; clicking it enters edit mode.
| Prop | Type | Default |
|---|---|---|
| children# | React.ReactNodePlaceholder text displayed when the value is empty | — |
| className# | stringCSS class name applied to the preview element | — |
| onClick# | (event: React.MouseEvent<HTMLSpanElement>) => voidCustom click handler (composed with built-in enter-edit handler) | — |
| onKeyDown# | (event: React.KeyboardEvent<HTMLSpanElement>) => voidCustom keydown handler (composed with built-in Enter/Space handler) | — |
Input
The text input element that appears during edit mode.
| Prop | Type | Default |
|---|---|---|
| className# | stringCSS class name applied to the input element | — |
| placeholder# | stringPlaceholder text shown when the input is empty | — |
| onChange# | (event: React.ChangeEvent<HTMLInputElement>) => voidCustom change handler (composed with built-in value tracking) | — |
| onKeyDown# | (event: React.KeyboardEvent<HTMLInputElement>) => voidCustom keydown handler (composed with submit/cancel handlers) | — |
| onBlur# | (event: React.FocusEvent<HTMLInputElement>) => voidCustom blur handler (composed with built-in submit handler) | — |
Source code
If you didn't find what you need here, read the component implementation .