Skip to content

Instantly share code, notes, and snippets.

@ejmudrak
Created December 5, 2023 16:21
Show Gist options
  • Select an option

  • Save ejmudrak/ba2eac6de8c0af8bacfffd1e02f565e2 to your computer and use it in GitHub Desktop.

Select an option

Save ejmudrak/ba2eac6de8c0af8bacfffd1e02f565e2 to your computer and use it in GitHub Desktop.
Accessible Password Input
<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