label-editable-react v1.5.5
EditableLabel
A simple React component for switching between a text label and a text input.
Clicking on the text label switches the label to a text input. A loss of focus on the text input will switch back to the text label and save the text changes.
An ESC key press will switch from text input back to label and discard any changes made to the text in the input.
An ENTER key press will switch from text input back to label and save any changes made.
When a save is triggered, the save function passed in as a prop is called with the current value of the input.
Live Demo
Table of Contents
Installation
$ npm install label-editable-react
$ yarn add label-editable-react
Usage
The EditableLabel object requires two props:
initialValuewhich is the initial text to displaysavewhich is the function called when the text is updated.
Optional props:
labelClasswhich is added to theclassNameof the label<span>tag.inputClasswhich is added to theclassNameof the text<input>tag.disableKeyswhich disables the keyPress handler.inputType: which is added to thetypeof the text<input>tag |default: text.heading: which is added above of label |default: ' '.isWebsite: if label is website set it to true |default: false.isEditIcon: No need of pencil icon set it to false |default: true.
Example:
Demo Repository
Original Repository
Note : Do Install react-bootstrap for better UI.