npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-link-textarea

v1.1.12

Published

Enhancing UX by breaking the limitations of original textarea tag, supports link integration and offers flexible styling options.

Downloads

53

Readme

What is it?

We all aim for a high UX.

Due to the structural limitation of the existing textarea tag, which only handles text values, it is difficult to develop to meet various requirements.

It makes the textarea tag work as if it supports the a tag.

You can use the existing textarea attributes, and CSS control such as resize is also possible.

Storybook

You can see various implementations of LinkingTextarea through Storybook. Click here!

Installation

npm install react-textarea-link

Usage

First step

...
"use client" // Add if you use next.js.
import LinkingTextarea from 'react-link-textarea'; // needs importing

const Component = () => {
  ...
}

Basic usage

const Section = () => {
  return (
    <>
      <div>
        <LinkingTextarea/>
      </div>
    </>
  );
};

export default Section;

With TailwindCSS

🔥 The className prop of JSX component is not provided. Use containerClassName and textareaClassName.

const Section = () => {
  return (
    <>
      <div className="w-full px-30 min-h-150">
        <LinkingTextarea
          containerClassName="w-full h-full"
          textareaClassName="pl-10 pr-10 rounded-md pt-10"
          fontColor="#5C5C5C"
          caretColor="#FEFEFE"
        />
      </div>
    </>
  );
};

With inline style

const Section = () => {
  return (
    <>
      <div
        style={{
          width: '100%',
          paddingLeft: 30,
          paddingRight: 30,
          minHeight: 150,
        }}>
        <LinkingTextarea
          containerStyle={{width: '100%', height: '100%'}}
          textareaStyle={{padding: 10, borderRadius: 12, resize: 'none'}}
          linkTarget="_self"
        />
      </div>
    </>
  );
};

Props API

ref                             --> HTMLTextAreaElement Ref is here, You can handle the textarea value and interaction.


containerStyle?: CSSProperties; --> Inline style to be passed to the part surrounding the textarea


textareaStyle?: CSSProperties;  --> Inline style to be passed to textarea (Textarea control CSS such as resize property can be used)


containerClassName?: string;    --> className to pass to container


textareaClassName?: string;     --> className to pass to textarea


linkTarget?: '_blank' | '_self' | '_parent' | '_top' | string  --> pass to a tag target attribute, default '_blank'.
// (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target)


fontColor?: CSSProperties['color'];        --> 🚨 Required when changing font color, default 'black' (CSS color property is used as is)
caretColor?: CSSProperties['caretColor'];  --> 🚨 Required when changing caret color, default 'black' (CSS color property is used as is)


// textarea attributes can be used on props

readOnly
autoComplete
...

(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attributes)
--> 🚨 Among the basic JSX textarea properties, only `style` and `className` are not accepted.

Example

Handling is possible through ref in the same way as previously using textarea.

const Section = () => {
  const textareaRef = useRef<HTMLTextAreaElement>(null);

  const onClickSubmit = () => {
    if (textareaRef.current) {
      console.log(textareaRef.current.value);
    }
  };

  useEffect(() => {
    if (!textareaRef.current) return;

    textareaRef.current.focus();
  }, []);

  return (
    <>
      <p>Textarea</p>
      <div>
        <LinkingTextarea ref={textareaRef} />
        <button onClick={onClickSubmit}></button>
      </div>
    </>
  );
};

Changelog

changelog.md