Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@thumbtack/tp-ui-react-textarea

thumbtack2UNLICENSEDdeprecated3.3.0

This package is deprecated in favor of the '@thumbtack/thumbprint-react' NPM package.

Textarea is a controlled component. This means that the visible text will always match the contents of the value prop.

readme


package: '@thumbtack/tp-ui-react-textarea' kit: element/textarea.yaml platform: react

url: /api/components/element/textarea/react/

Textarea with state management

Textarea is a controlled component. This means that the visible text will always match the contents of the value prop.

In this example, notice how value is stored within this.state. The onChange function will set the new value when the user enters or removes a character in the textarea.

class TextareaExample extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            value: '',
        };

        this.onChange = this.onChange.bind(this);
    }

    onChange(newValue) {
        this.setState({
            value: newValue,
        });
    }

    render() {
        return (
            <div>
                <Label text="Business description">
                    <Textarea
                        value={this.state.value}
                        placeholder="Tell us about your business"
                        onChange={this.onChange}
                    />
                </Label>
            </div>
        );
    }
}

Disabled textarea

The isDisabled prop disables the Textarea visually and functionally.

<Textarea isDisabled placeholder="Tell us about your business" onChange={() => {}} />

Textarea with an error

The hasError prop only changes the textarea’s color. It should be used alongside an error message that helps users advance through the form.

<Textarea
    hasError
    placeholder="Tell us about your business"
    value="We provide DJ services in Austin and have been in business for 25 years."
    onChange={() => {}}
/>

changelog

Changelog

Unreleased

3.3.0 - 2018-12-06

Added

  • [Minor] Pass entire event object as second argument to onChange.

3.2.6 - 2018-12-03

Changed

  • [Patch] Use a tilde for Sass imports (#1256)

3.2.5 - 2018-12-03

Changed

  • [Patch] Upgrade to latest version of eslint.

3.2.4 - 2018-11-27

Changed

  • [Patch] Publish package to public NPM.

3.2.3 - 2018-10-22

Changed

  • [Patch] Convert to use MDX for documentation. (#1251)

3.2.2 - 2018-10-03

Changed

  • [Patch] Remove defaultValue for value since it is required.

3.2.1 - 2018-09-12

Changed

  • [Patch] Upgrade version of Prettier and Thumbprint Tokens.

3.2.0 - 2018-08-17

Added

  • [Minor] Add support for dataTest prop

3.1.1 - 2018-08-10

Changed

  • [Patch] Use camelCase classes in CSS modules.

3.1.0 - 2018-06-13

Added

  • [Minor] Add an id prop for pairing the form field with a label.

3.0.0 - 2018-05-16

Changed

  • [Major] Use CSS modules instead of styled-components. (#865)

2.0.4 - 2018-04-19

Changed

  • [Patch] Fix mistake where CommonJS package was published as ES module. (#822)

2.0.3 - 2018-04-16

Changed

  • [Patch] Use latest version of Thumbprint Tokens.

2.0.2 - 2018-04-13

Changed

  • [Patch] Publish package as CommonJS and ES module.

2.0.1 - 2018-03-14

Changed

  • [Patch] Use latest version of Thumbprint Tokens.

2.0.0 - 2018-03-01

Added

  • [Minor] Add a hasError prop to visually indicate that there is an error.

Changed

  • [Major] Change default height to 154px.

Removed

  • [Major] Remove height prop.
  • [Major] Remove isReadOnly prop.

1.0.0 - 2017-02-20

1.0.0-1 - 2018-02-15

Changed

  • [Major] onChange returns event value, not the entire event. (#332, #400)

1.0.0-0 - 2018-02-14

Changed

  • [Major] Require value prop and add a default value of '' to prevent use as an uncontrolled component. (#331, #388)

0.7.2 - 2018-02-07

Changed

  • [Patch] Use latest version of Thumbprint Tokens.

0.7.1 - 2018-01-30

Changed

  • [Patch] Add support for styled-components ^3.0.0 to peer dependencies.

0.7.0 - 2018-01-16

Changed

  • [Minor] Use latest version of Thumbprint Tokens. This includes new brand colors.

0.6.2 - 2018-01-11

Changed

  • [Patch] Update npm latest tag since it was accidentally pointed to a prepublish version of our components.

0.6.1 - 2017-12-11

Changed

  • [Patch] Run babel-plugin-styled-components before publishing component.

0.6.0 - 2017-12-01

  • [Minor] Add maxLength prop, preventing onChange from firing if new text will exceed value.

0.5.3 - 2017-11-21

Changed

  • [Patch] Rewrite documentation with Gatsby.
  • [Patch] Use Prettier to format files.

0.5.2 - 2017-11-16

Changed

  • [Patch] Change peerDependencies to include React 16.

0.5.1 - 2017-11-01

Changed

  • [Major] Move styled-components from dependencies to peerDependencies.

0.5.0 - 2017-10-31

Changed

  • [Patch] Update @thumbtack/thumbprint-tokens to version 4.0.1.

Removed

  • [Major] Remove auto option to height prop. It was not used and causing issues. (#415)

0.4.0 - 2017-10-18

Added

  • [Minor] Add auto option to height prop for textarea's that grow automatically. (#385)

0.3.0 - 2017-10-18

Changed

  • [Minor] Add onBlur and onFocus props. (#387)

0.2.4 - 2017-10-13

Changed

  • [Patch] Border color now $tp-color__ui__pale, replacing $tp-color__ui__base as it was too light.

0.2.3 - 2017-10-04

Changed

  • [Patch] Use latest version of thumbprint-tokens.

0.2.2 - 2017-10-02

Fixed

  • [Patch] Change how we import component in Jest to avoid a bizarre Jest bug.

0.2.1 - 2017-08-07

Changed

  • [Patch] Increase specificity of generated CSS for component to take precedence. (#244)

0.2.0 - 2017-07-19

Changed

  • [Major] Convert Textarea to a controlled component. This removes the defaultValue prop in favor of a value prop.

0.1.1 - 2017-07-13

Added

  • [Patch] Add component tests.

Changed

  • [Patch] Update code to conform to ESLint standards.

0.1.0 - 2017-07-10

Added

  • [Minor] Create first version of tp-ui-react-textarea.