Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Semantic-UI-React, is there a way to add an x icon to a text input or dropdown that will clear the text when clicked?

I have both a text input and a dropdown that allows additions (both use the Form.xxx version). For both of these, I would like to add an x icon on the right, that when clicked, will either call a handler or will clear the input's value.

Is this possible in semantic-ui-react?

Thank you

like image 756
mdebeus Avatar asked Mar 02 '18 20:03

mdebeus


1 Answers

I did find a solution, which I will share, but this means I can no longer have my lock icon on the left hand side, because an input can only have one icon.

What I've done is to use an Icon element, and add an onClick handler to that, as follows:

<Input ...
  icon={<Icon name='delete' link onClick={this.handleDeleteClick}/>}/>
like image 85
mdebeus Avatar answered Oct 15 '22 07:10

mdebeus