react-tagsinput icon indicating copy to clipboard operation
react-tagsinput copied to clipboard

How do I add icon at the beginning of the component?

Open aayushdutt opened this issue 5 years ago • 3 comments

Example: image

aayushdutt avatar Jun 23 '20 04:06 aayushdutt

Hello @aayushdutt, were you able to add the icon?

afvr94 avatar Jul 10 '20 17:07 afvr94

@afvr94 Nope. I still need help regarding this.

aayushdutt avatar Jul 10 '20 17:07 aayushdutt

You should use renderInput prop, so something like this

const defaultRenderInput = (props) => {
    let { onChange, value, addTag, ...other } = props;
    return (
      <span>
        <Box
          position="relative"
          top="3px"
          as={AiOutlineSearch}
          color="#f8b700"
        ></Box>
        <input type="text" onChange={onChange} value={value} {...other} />
      </span>
    );
  };

Box component in this case is acting as an icon that will appear in front of the input field.

<TagsInput
        renderInput={defaultRenderInput}
        onChange={(e) => handleTags(e)}
        value={tags}
      />

empyreanmw avatar Dec 21 '20 17:12 empyreanmw