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 component
import { Editable } from '@fintech-sandpit/ui/react';
// Import styles (optional)
import '@fintech-sandpit/ui/style/components/editable.css';
const [value, setValue] = useState('Hello, world!');
return (
<Editable
value={value}
onChange={setValue}
/>
);
NameTypeDefaultDescription
valuestring—The value of the editable field (controlled)
defaultValuestring—The default value of the editable field (uncontrolled)
placeholderstring—The 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
editTriggerReactNode—The trigger component to edit the value
saveTriggerReactNode—The trigger component to save the value
cancelTriggerReactNode—The 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
onValueChange(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