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 🙏

© 2025 – Pkg Stats / Ryan Hefner

jb-textarea

v3.11.0

Published

textarea web component

Readme

jb-textarea

Published on webcomponents.org GitHub license NPM Downloads

simple textarea web component to input long text

  • lightweight
  • zero dependency
  • advance validation with jb-validation module
  • help you manage validation in easy way
  • config auto height grow ability with max height
  • web component so you can use it with any framework you need

Demo

  • storybook
  • [codepen][https://codepen.io/javadbat/pen/poRZVXe]

using with JS frameworks

to use this component in react see jb-textarea/react;

installation and setup

npm i jb-textarea
<jb-textarea label="description" value="" message="text under the textarea box"></jb-textarea>

get and set value

document.querySelector("jb-textarea").value;
// return inputted text
document.querySelector("jb-textarea").value = "hello";
set value to hello

set validation

jb-textarea use jb-validation inside to handle validation so for more information you can read it's documentation.
for simple usage you can set validation to your input:

//you have 2 ways: 
//1- set list directly 
    description.validation.list = [
        {
            validator: /.{3}/g,
            message: 'description must have 3 char at least'
        },
    //you can use function as a validator too
        {
            validator: (valueString)=>{return valueString == "hello"},
            message: 'you can only type hello in the box'
        },
    //you can also return string in validator if you want custom error message in some edge cases
        {
            validator: (valueString)=>{
               if(valueString.includes("*")){
                return 'you cant write * in your text'
               }
               return true;
            },
            message: 'default error when return false'
        },
    ];
//2- pass a function that returns the validation list so on each validation process we execute your callback function and get the needed validation list
const result = document.getElementByTagName('jb-textarea').validation.addValidationListGetter(getterFunction)

check validation

like any other jb design system you can access validation by validation property:

//access validation module
document.getElementByTagName('jb-textarea').validation
// check if input pass all the validations. showError is a boolean that determine your intent to show error to user on invalid status.
const result = document.getElementByTagName('jb-textarea').validation.checkValidity(showError)

events

document.querySelector("jb-textarea").addEventListener('change',func);
document.querySelector("jb-textarea").addEventListener('keydown',func);
document.querySelector("jb-textarea").addEventListener('keyup',func);
document.querySelector("jb-textarea").addEventListener('keypress',func);
document.querySelector("jb-textarea").addEventListener('input',func);
// custom Keyboard event that raise when user press enter (unlike jb-input this enter event raise after keypress because it could be cancelled with prevent default)
document.querySelector("jb-textarea").addEventListener('enter',func);

auto height grow

you can set autoHeight to true so when user type something and text overflow a textarea height component will grow by itself in boundary of --jb-textarea-min-height and --jb-textarea-max-height that you set by css variable

document.querySelector("jb-textarea").autoHeight = true;

the good point of set boundary with css variable is you can set different min or max base on device by CSS media queries.

set custom style

you have 2 way to customize style,

  1. using selectors like:states or ::part selector
jb-textarea::part(label){
  font-size: 2rem;
}
jb-textarea:states(invalid)::part(label){
  color:red;
}

we have label, textarea-box, textarea, message as a supported part in our component. you can also combine them with disabled, invalid states for different style in different states.

  1. using css variable

| css variable name | description | | ------------- | ------------- | | --jb-textarea-margin | web-component margin default is 0 12px | | --jb-textarea-border-radius | web-component border-radius | | --jb-textarea-border-width | web-component border-width default is 1px | | --jb-textarea-border-color | border color of select in normal mode | | --jb-textarea-border-color-disabled | border color when disabled | | --jb-textarea-border-color-focus | border color of select in normal mode | | --jb-textarea-bgcolor | background color of input | | --jb-textarea-bgcolor-disabled | background color of input when disabled | | --jb-textarea-border-bottom-width | border bottom thickness default is 3px | | --jb-textarea-label-font-size | font size of input label default is 0.8em | | --jb-textarea-value-font-size | font size of input value default is 1.1em | | --jb-textarea-value-color | color of value | | --jb-textarea-value-color-disabled | color of value when disabled | | --jb-textarea-message-font-size | font size of message we show under input | | --jb-textarea-message-error-color | change color of error we show under input | | --jb-textarea-min-height | minimum height of text area default is 80px | | --jb-textarea-max-height | minimum height of text area default is none | | --jb-textarea-placeholder-color | placeholder color default is 'initial' | | --jb-textarea-placeholder-font-size | placeholder font-size default is initial | | --jb-textarea-label-color | label color |
| --jb-textarea-label-color-disabled | label color when disabled |

add custom element in textarea box

in jb-textarea you can put icon or any other custom html DOM in textarea box. to doing so you just have to place custom DOM in jb-textarea tag and add slot="inline-start-section" or slot="inline-end-section" or slot="block-start-section" or slot="block-end-section" to place it before or after input field. example:

<jb-textarea>
    <div slot="inline-start-section">before</div>
    <div slot="inline-end-section">after</div>
</jb-textarea>

Other Related Docs: