Back to Woocommerce

README

packages/js/components/src/text-control-with-affixes/README.md

10.8.0-dev1.6 KB
Original Source

TextControlWithAffixes

This component is essentially a wrapper (really a reimplementation) around the TextControl component that adds support for affixes, i.e. the ability to display a fixed part either at the beginning or at the end of the text input.

Usage

jsx
<TextControlWithAffixes
    suffix="%"
    label="Text field with a suffix"
    value={ fourth }
    onChange={ value => setState( { fourth: value } ) }
/>
<TextControlWithAffixes
    prefix="$"
    label="Text field with prefix and help text"
    value={ fifth }
    onChange={ value => setState( { fifth: value } ) }
    help="This is some help text."
/>

Props

NameTypeDefaultDescription
labelStringnullIf this property is added, a label will be generated using label property as the content
helpStringnullIf this property is added, a help text will be generated using help property as the content
typeString'text'Type of the input element to render. Defaults to "text"
valueStringnull(required) The current value of the input
classNameStringnullThe class that will be added with "components-base-control" to the classes of the wrapper div. If no className is passed only components-base-control is used
onChangeFunctionnull(required) A function that receives the value of the input
prefixReactNodenullMarkup to be inserted at the beginning of the input
suffixReactNodenullMarkup to be appended at the end of the input
disabledBooleannullDisables the field