mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
27 lines
860 B
TypeScript
27 lines
860 B
TypeScript
import { useState } from "react";
|
|
import { EyeIcon, EyeOffIcon } from "lucide-react";
|
|
import { Input, type InputProps } from "../ui/input";
|
|
import { Button } from "../ui/button";
|
|
|
|
export const ToggleVisibilityInput = ({ ...props }: InputProps) => {
|
|
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
|
|
|
|
const togglePasswordVisibility = () => {
|
|
setIsPasswordVisible((prevVisibility) => !prevVisibility);
|
|
};
|
|
|
|
const inputType = isPasswordVisible ? "text" : "password";
|
|
return (
|
|
<div className="flex w-full items-center space-x-2">
|
|
<Input type={inputType} {...props} />
|
|
<Button onClick={togglePasswordVisibility} variant={"secondary"}>
|
|
{inputType === "password" ? (
|
|
<EyeIcon className="size-4 text-muted-foreground" />
|
|
) : (
|
|
<EyeOffIcon className="size-4 text-muted-foreground" />
|
|
)}
|
|
</Button>
|
|
</div>
|
|
);
|
|
};
|