Created
December 5, 2023 16:21
-
-
Save ejmudrak/ba2eac6de8c0af8bacfffd1e02f565e2 to your computer and use it in GitHub Desktop.
Accessible Password Input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <TextField | |
| type={showPassword ? 'text' : 'password'} | |
| InputProps={{ | |
| endAdornment: ( | |
| <IconButton | |
| aria-pressed={showPassword ? 'true' : 'false'} | |
| aria-label='toggle password visibility' | |
| onClick={() => setShowPassword((prev) => !prev)} | |
| > | |
| {showPassword ? <VisibilityOff /> : <Visibility />} | |
| </IconButton> | |
| ), | |
| }} | |
| /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment