# react-edit-text

> Simple editable text component for React

Latest version **5.1.1** (published 2023-07-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-edit-text
pnpm add react-edit-text
yarn add react-edit-text
bun add react-edit-text
```

## Health

**Score 18/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.1.1 |
| Published | 2023-07-12 |
| First published | 2020-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/react-edit-text) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 54 |
| Author | Brian Min |
| Maintainers | brianmin15 |
| Keywords | react, edit, text, react-edit-text, editable, inline-edit, input, textbox, textarea |

## Links

- npm: https://www.npmjs.com/package/react-edit-text
- Repository: https://github.com/bymi15/react-edit-text
- Homepage: https://github.com/bymi15/react-edit-text#readme
- Issues: https://github.com/bymi15/react-edit-text/issues
- npm.io page: https://npm.io/package/react-edit-text

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 5.1.1 (latest) — 2023-07-12
- 5.1.0 — 2023-03-14
- 5.0.2 — 2022-06-08
- 5.0.1 — 2022-06-02
- 5.0.0 — 2022-06-01
- 4.4.1 — 2022-05-30
- 4.4.0 — 2022-03-21
- 4.3.0 — 2022-03-01
- 4.2.0 — 2021-08-22
- 4.1.0 — 2021-07-26
- 4.0.3 — 2021-04-03
- 4.0.2 — 2021-04-03
- 4.0.1 — 2021-03-09
- 4.0.0 — 2021-02-19
- 3.0.1 — 2021-01-13
- … 9 more at https://npm.io/package/react-edit-text/versions

## README

<h1 align="center">React Edit Text</h1>

<p align="center">
    <a href="https://sonarcloud.io/dashboard?id=bymi15_react-edit-text">
        <img src="https://sonarcloud.io/api/project_badges/measure?project=bymi15_react-edit-text&metric=alert_status" alt="Quality Gate Status" />
    </a>
    <a href="https://travis-ci.com/github/bymi15/react-edit-text">
        <img src="https://api.travis-ci.com/bymi15/react-edit-text.svg?branch=main" alt="travis" />
    </a>
    <a href="https://www.npmjs.com/package/react-edit-text">
        <img src="https://img.shields.io/npm/v/react-edit-text?color=brightgreen&style=flat-squaret" alt="npm" />
    </a>
    <a href="https://www.npmjs.com/package/react-edit-text">
        <img src="https://img.shields.io/npm/dt/react-edit-text.svg?color=brightgreen&style=flat-squaret" alt="npm" />
    </a>
</p>

<p align="center">This is an easy-to-use <b>editable text component</b> for <a href="https://reactjs.org/">React</a>. Simply click on the textbox to edit!</p>

<p align="center">Made with <span role="img" aria-label="love">❤️</span> by <a href="https://github.com/bymi15">Brian Min</a></p>

<p align="center">
	<img alt="demo" src="https://raw.githubusercontent.com/bymi15/react-edit-text/main/demo.gif"/>
</p>

## Demo

Please visit https://brianmin.com/react-edit-text/ for a live demo and various examples.

## Install

```bash
npm install react-edit-text --save
```

## Type definitions

```bash
npm install @types/react-edit-text --save-dev
```

## Usage

Make sure to import the <b>CSS stylesheet</b> before using the component.

```jsx
import React from 'react';

import { EditText, EditTextarea } from 'react-edit-text';
import 'react-edit-text/dist/index.css';

export default function Example() {
  return (
    <div>
      <EditText showEditButton />
      <EditTextarea />
    </div>
  );
}
```

## Props

### Shared props

| Prop              | Type     | Required | Default  | Description                                                           |
| ----------------- | -------- | -------- | -------- | --------------------------------------------------------------------- |
| id                | string   | No       |          | HTML DOM id attribute                                                 |
| name              | string   | No       |          | HTML input name attribute                                             |
| className         | string   | No       |          | HTML class attribute for the display component                        |
| inputClassName    | string   | No       |          | HTML class attribute for the input component                          |
| value             | string   | No       |          | Value of the component                                                |
| defaultValue      | string   | No       |          | Default value of the component                                        |
| placeholder       | string   | No       | ''       | Placeholder value                                                     |
| formatDisplayText | function | No       | (x) => x | Callback function applied on the value to display the formatted value |
| onSave            | function | No       |          | Callback function triggered when input is saved                       |
| onChange          | function | No       |          | Callback function triggered when input is changed                     |
| onEditMode        | function | No       |          | Callback function triggered when component is clicked                 |
| onBlur            | function | No       |          | Callback function triggered when input is blurred                     |
| style             | object   | No       |          | Sets CSS style of input and view component                            |
| readonly          | bool     | No       | false    | Disables the input and only displays the view component               |

### EditText props

| Prop              | Type   | Required | Default                                                              | Description                                                                   |
| ----------------- | ------ | -------- | -------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| type              | string | No       | 'text'                                                               | HTML DOM input text type                                                      |
| inline            | bool   | No       | false                                                                | Sets inline display                                                           |
| showEditButton    | bool   | No       | false                                                                | Displays an edit button that can be pressed to enable edit mode               |
| editButtonContent | node   | No       | <img src="./assets/images/editIcon.png" alt="editIcon" width="15" /> | Sets the content for the edit button. This can be any valid element           |
| editButtonProps   | object | No       | {}                                                                   | Sets the props passed to the edit button. This can be any valid DOM attribute |

### EditTextarea props

| Prop | Type             | Required | Default | Description            |
| ---- | ---------------- | -------- | ------- | ---------------------- |
| rows | number \| 'auto' | No       | 3       | Number of visible rows |

## Contributing

Contributions are very much appreciated and welcome.
Please refer to the [contributing guidelines](https://github.com/bymi15/react-edit-text/blob/main/CONTRIBUTING.md) for more details.

## License

MIT © [Brian Min](https://github.com/bymi15)

---
_Source: https://npm.io/package/react-edit-text · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
