Git Product home page Git Product logo

react-highlight-within-textarea's Introduction

react-highlight-within-textarea

React component for highlighting bits of text within a textarea

NPM JavaScript Style Guide Yarn Test

Install

npm install --save react-highlight-within-textarea

Usage

import React from 'react';
import { useState } from 'react';
import { HighlightWithinTextarea } from 'react-highlight-within-textarea'

const Example = () => {
  const [value, setValue] = useState("X Y Z and then XYZ");
  return (
    <HighlightWithinTextarea
      value={value}
      highlight={/[XYZ]/g}
      onChange= {event => setValue(event.target.value)}
    />
  );
};

The highlight property accepts several different types of values to describe what will be highlighted. You can see the various ways to highlight things, along with example code, on the demo page.

Properties

There are two notable elements within this component. These are the textarea and its surrounding container which facilitates the highlighting. Unless otherwise specified below, properties will be applied to the textarea. Some customization (like width) will need to be applied to both.

value: In React, you must supply a value and update it within the textarea.

onChange: In React, you must supply an onChange function that updates the value.

highlight: This specifies what to highlght. For more info, see the demo page.

containerStyle: Some textarea styles will also have to be applied to the surrounding container. This directly applies to the container.

containerClassName: This adds classes to the surrounding container.

all-other-properties: All other properties will be directly applied to the textarea.

Known Issues

Currently, textarea resizing is not supported.

License

MIT © bonafideduck


react-highlight-within-textarea's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.