mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-20 08:15:26 +02:00
43 lines
899 B
TypeScript
43 lines
899 B
TypeScript
import {MdVisibility, MdVisibilityOff} from "react-icons/md"
|
|
import React, {ReactElement, useState} from "react"
|
|
|
|
import {
|
|
IconButton,
|
|
InputAdornment,
|
|
TextField,
|
|
TextFieldProps,
|
|
} from "@mui/material"
|
|
|
|
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>
|
|
),
|
|
}}
|
|
/>
|
|
)
|
|
}
|