diff options
| author | l3wdfut4pwr <l3wdfut4pwr@gmail.com> | 2026-03-17 21:51:22 +0200 |
|---|---|---|
| committer | l3wdfut4pwr <l3wdfut4pwr@gmail.com> | 2026-03-17 21:51:22 +0200 |
| commit | 293df20781b8f0ae6fcbabb1a33b3d1752e494c8 (patch) | |
| tree | 11fdda5346a44a66be97eda49cb61b86c28388b4 /src/components/ui/input.tsx | |
| parent | 646c1168349643eb01db53b5e06bf986a16b86d7 (diff) | |
add password toggle button
Diffstat (limited to 'src/components/ui/input.tsx')
| -rw-r--r-- | src/components/ui/input.tsx | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/components/ui/input.tsx b/src/components/ui/input.tsx index 0424772..7dd5b62 100644 --- a/src/components/ui/input.tsx +++ b/src/components/ui/input.tsx @@ -1,9 +1,27 @@ +'use client'; + import { cn } from '@/lib/utils'; -import React from 'react'; +import { useState } from 'react'; +import ShowIcon from '@icons/show-icon.svg'; +import HideIcon from '@icons/hide-icon.svg'; -export function Input({ - className, - ...props -}: React.InputHTMLAttributes<HTMLInputElement>) { - return <input className={cn('outline-none', className)} {...props} />; +export function Input({ className, isPassword, ...props }: any) { + const [show, setShow] = useState(false); + return ( + <div className="relative w-full"> + <input + {...props} + type={isPassword ? (show ? 'text' : 'password') : props.type} + className={cn('w-full outline-none', className)} + /> + {isPassword && ( + <span + onClick={() => setShow(!show)} + className="absolute right-0 top-1/2 -translate-y-1/2 cursor-pointer" + > + {show ? <ShowIcon /> : <HideIcon />} + </span> + )} + </div> + ); } |
