File size: 817 Bytes
091fca4
2f65818
 
 
 
a077d00
091fca4
2f65818
091fca4
2f65818
091fca4
 
884bca0
091fca4
 
 
a077d00
091fca4
 
 
 
 
 
 
 
 
 
 
2f65818
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { IconButton, InputAdornment, TextField, TextFieldProps } from "@mui/material";
import { useState } from "react";
import { Visibility, VisibilityOff } from "@mui/icons-material";

export default function Secret(props: TextFieldProps) {
	const { name = "secret", label = "Secret", required = true } = props;
	const [showSecret, setShowSecret] = useState(false);

	const handleShowSecret = () => setShowSecret(!showSecret);

	return (
		<TextField
			variant="outlined"
			label={label}
			name={name}
			type={showSecret ? "text" : "password"}
			required={required}
			InputProps={{
				endAdornment: (
					<InputAdornment position="end">
						<IconButton onClick={handleShowSecret}>
							{showSecret ? <Visibility /> : <VisibilityOff />}
						</IconButton>
					</InputAdornment>
				),
			}}
		/>
	);
}