langfuse

Форк
0
/
password-input.tsx 
42 строки · 1.5 Кб
1
import * as React from "react";
2
import { cn } from "@/src/utils/tailwind";
3
import { Eye, EyeOff } from "lucide-react";
4

5
export interface PasswordInputProps
6
  extends React.InputHTMLAttributes<HTMLInputElement> {}
7

8
const PasswordInput = React.forwardRef<HTMLInputElement, PasswordInputProps>(
9
  ({ className, ...props }, ref) => {
10
    const [showPassword, setShowPassword] = React.useState(false);
11

12
    return (
13
      <div className="relative">
14
        <input
15
          type={showPassword ? "text" : "password"}
16
          className={cn(
17
            "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 pr-10 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
18
            className,
19
          )}
20
          ref={ref}
21
          {...props}
22
        />
23
        <button
24
          type="button"
25
          className="absolute right-3 top-1/2 -translate-y-1/2 transform cursor-pointer"
26
          onClick={() => setShowPassword(!showPassword)}
27
          title={showPassword ? "Hide password" : "Show password"}
28
        >
29
          {showPassword ? (
30
            <EyeOff className="h-5 w-5 text-gray-400" />
31
          ) : (
32
            <Eye className="h-5 w-5 text-gray-400" />
33
          )}
34
        </button>
35
      </div>
36
    );
37
  },
38
);
39

40
PasswordInput.displayName = "PasswordInput";
41

42
export { PasswordInput };
43

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.