How can I hide and show password text #5255
-
For the following code, I want to make password text hide and show. How can I do? <md-outlined-text-field label="password" type="password" name="Password">
<md-icon-button toggle slot="trailing-icon" form="">
@* show btn *@
<md-icon>visibility</md-icon>
@* hide btn *@
<md-icon slot="selected">visibility_off</md-icon>
</md-icon-button>
</md-outlined-text-field> |
Beta Was this translation helpful? Give feedback.
Answered by
asyncLiz
Dec 5, 2023
Replies: 1 comment 3 replies
-
Add a click listener to the icon button and swap the text field's type with https://lit.dev/playground/#gist=f64f6ee859231ab1e0c955b5a9153afc iconbutton.addEventListener('click', () => {
textfield.type = iconbutton.selected ? 'text' : 'password';
}); |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
Staler2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add a click listener to the icon button and swap the text field's type with
password
ortext
https://lit.dev/playground/#gist=f64f6ee859231ab1e0c955b5a9153afc