Skip to content

TextInput rightIcon onclick toggle icon #653

Answered by mikenath223
swanil009 asked this question in Q&A
Discussion options

You must be logged in to vote

So this worked for me:

      <TextInput
          className="flex h-full grow p-0"
          sizing="sm"
          name="password"
          type="password"
          rightIcon={() =>
          !showPassword ? (
            <EyeIcon
               onClick={() => setShowPassword(!showPassword)}
               className="cursor-pointer"
               fontSize={12}
               width={16}
            />
           ) : (
            <EyeSlashIcon
               onClick={() => setShowPassword(!showPassword)}
               className="cursor-pointer"
               fontSize={12}
               width={16}
            />
           )
          }
       />

Then add this to your globals.css:

  […

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@swanil009
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by rluders
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants