Skip to content

Editable

A component that allows users to edit text in place.

Hello, world!
Mode:viewing
Value:"Hello, world!"
import { useState } from 'react';
import { Editable } from '@fintech-sandpit/ui/react';
const [value, setValue] = useState('Hello, world!');
return (
<Editable
value={value}
onChange={setValue}
/>
);
NameTypeDefaultDescription
valuestringThe value of the editable field (controlled)
defaultValuestringThe default value of the editable field (uncontrolled)
placeholderstringThe placeholder of the editable field
activateModeActivationModeclickThe activation mode for the preview element
submitModeSubmitModeblurThe action that triggers submit in the edit mode
multilinebooleanfalseWhether the editable field is multiline (textarea)
disabledbooleanfalseWhether the editable field is disabled
editTriggerReactNodeThe trigger component to edit the value
saveTriggerReactNodeThe trigger component to save the value
cancelTriggerReactNodeThe trigger component to cancel the edit
NameDescription
edit-triggerThe trigger component to edit the value
save-triggerThe trigger component to save the value
cancel-triggerThe trigger component to cancel the edit
NameTypeDescription
onChange(value: string) => voidCallback fired when the value change is committed
onEditChange(edit: boolean) => voidCallback fired when the edit state changes
type ActivationMode = 'focus' | 'click' | 'dblclick' | 'none'
ValueDescription
focusEnter edit mode when the preview is focused
clickEnter edit mode when the preview is double-clicked
dblclickEnter edit mode when the preview is clicked
noneEdit can be triggered programmatically only
type SubmitMode = 'none' | 'blur' | 'enter' | 'both'
ValueDescription
noneNo action will trigger submit. You need to use the submit button
blurTrigger submit when the editable is blurred
enterTrigger submit when the enter key is pressed
bothPressing Enter and blurring the input will trigger submit