AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

password-input.tsx 1.3KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { Eye, EyeOff } from 'lucide-react';
  2. import type { ComponentProps, Ref } from 'react';
  3. import { useState } from 'react';
  4. import { Input } from '@/components/ui/input';
  5. import { cn } from '@/lib/utils';
  6. export default function PasswordInput({
  7. className,
  8. ref,
  9. ...props
  10. }: Omit<ComponentProps<'input'>, 'type'> & { ref?: Ref<HTMLInputElement> }) {
  11. const [showPassword, setShowPassword] = useState(false);
  12. return (
  13. <div className="relative">
  14. <Input
  15. type={showPassword ? 'text' : 'password'}
  16. className={cn('pr-10', className)}
  17. ref={ref}
  18. {...props}
  19. />
  20. <button
  21. type="button"
  22. onClick={() => setShowPassword((prev) => !prev)}
  23. className="absolute inset-y-0 right-0 flex items-center rounded-r-md px-3 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring focus-visible:outline-none"
  24. aria-label={showPassword ? 'Hide password' : 'Show password'}
  25. tabIndex={-1}
  26. >
  27. {showPassword ? (
  28. <EyeOff className="size-4" />
  29. ) : (
  30. <Eye className="size-4" />
  31. )}
  32. </button>
  33. </div>
  34. );
  35. }