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-text-input

v0.0.8

Published

Textarea and input components with custom scrollbars and aurogrow in both axes

Downloads

1,560

Readme

React Text Input

npm version

Live Demo

Motivation

  • Use arbitrary markup in placeholder even icons, animation etc.
  • Customize scrollbars for TextArea. Done with help of react-scroll-box.
  • Enable vertical and horizontal autogrow that is fully controlled from CSS for Input and TextArea.
  • Use components in either controlled or uncontrolled way.

Usage

var TextArea = require('react-text-input').TextArea; // ES5

import {Input, TextArea, GenericInput} from 'react-text-input'; // ES6

<TextArea defaultValue="Hello world!"/>

Components

This pakage provides three React components:

GenericInput

Abstract component that expects arbitrary editing control as a child. Manages placeholder and autogow.

Prop Name | Type | Default | Description --- | --- | --- | --- value | String | | Value represented by this GenericInput. disabled | Boolean | false | Toggles component disabled with .text-input--disabled. placeholder | * | | Any value including React element, that is displayed if value is empty. className | String | | Style class name added to root element.

Input

One line text input component. Generally behaves like regular input. Inherits all properties from GenericInput and regular input.

Prop Name | Type | Default | Description --- | --- | --- | --- value | String | | Value represented by this Input if it is controlled. defaultValue | String | | Default value represented by this Input if it is uncontrolled. fitLineLength | Boolean | false | Should.

Uncontrolled input component markup:

<Input type="search"
       defaultValue="Christmas gifts"
       placeholder={<span><i className="fa fa-search"/> Search</span>}
       fitLineLength={true}/>

TextArea

Autogrowing text area implementation. Has all the same properties as Input.

<TextArea fitLineLength={true}
          onChange={e => console.log(e.target.value)}/>

Styles

By default, components have no visual decoration, so you need to provide a custom class name (like form-control from Bootstrap) to make it them visible.

In most cases you should change styling only for the root DOM element. Styles applied to Input and TextArea behave just like regular input and textare elements do.

Class Name | Description --- | --- .text-input | Root style class for both Input and TextArea .text-input--filled | Added when component stores a non-empty value. .text-input--disabled | Added when component is disabled. .text‑input‑‑fit‑line‑length | Added when component should grow horizontally. .text-input--text | Modifier that matches type of input control. For example, input[type="password"] would have .text-input--passwordspecified. <code>.text-input--text-area</code> | Added fortextareacontrol. <code>.text-input__control</code> | HTML UI elementinputortextarea. <code>.text-input__placeholder</code> | Placeholder container. Content of the placeholder` prop is rendered inside this container. .text-input__content | Container that stores input text. Required for autogrow.

Autogrowing

By default, TextArea has height of a single line of text and grows vertically without any limit. You can constraint vertical expansion with min-height and max-height.

.vertical-constraint {
  min-height: 100px;
  max-height: 200px;
}

Then provide this modifier as a className value.

<TextArea className="vertical-constraint"/>

Horizontal constraints work in the same way for both Input and TextArea when fitLineLength={true} specified.

.horizontal-constraint {
  min-width: 100px;
  max-width: 200px;
}

License

The code is available under MIT licence.