mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-18 15:35:26 +02:00
42 lines
891 B
TypeScript
42 lines
891 B
TypeScript
import {
|
|
IconButton,
|
|
InputAdornment,
|
|
TextField,
|
|
TextFieldProps,
|
|
} from "@mui/material"
|
|
import {ReactElement, useState} from "react"
|
|
import {MdVisibility, MdVisibilityOff} from "react-icons/md"
|
|
|
|
export interface PasswordFieldProps extends Omit<TextFieldProps, "type"> {}
|
|
|
|
export default function PasswordField({
|
|
InputProps = {},
|
|
...props
|
|
}: PasswordFieldProps): ReactElement {
|
|
const [showPassword, setShowPassword] = useState<boolean>(false)
|
|
|
|
return (
|
|
<TextField
|
|
{...props}
|
|
type={showPassword ? "text" : "password"}
|
|
InputProps={{
|
|
...InputProps,
|
|
endAdornment: (
|
|
<InputAdornment position="end">
|
|
<IconButton
|
|
edge="end"
|
|
onClick={() => setShowPassword(value => !value)}
|
|
>
|
|
{showPassword ? (
|
|
<MdVisibilityOff />
|
|
) : (
|
|
<MdVisibility />
|
|
)}
|
|
</IconButton>
|
|
</InputAdornment>
|
|
),
|
|
}}
|
|
/>
|
|
)
|
|
}
|