Password Input

Champ de mot de passe avec bascule de visibilite integree. Installez Password Input depuis le registre VLLNT UI avec la CLI shadcn.

Signaler un bug

Champ de mot de passe avec bascule de visibilite integree. Fait partie de la famille form dans VLLNT UI, il est publie comme entree de registre lisible par machine — copiez la source directement dans votre application avec la CLI shadcn et possedez-la, sans dependance d'execution a une bibliotheque de composants.

Apercu

Basculez entre clair et sombre pour inspecter l'apercu Storybook integre.

Installation

Ajoutez Password Input a votre projet avec la CLI shadcn. La source arrive dans votre code, prete a etre adaptee :

pnpm dlx shadcn@latest add https://ui.vllnt.ai/r/password-input.json

Source

"use client"; import * as React from "react"; import { Eye, EyeOff } from "lucide-react"; import { cn } from "../../lib/utils"; export type PasswordInputProps = Omit< React.ComponentPropsWithoutRef<"input">, "type" > & { hideLabel?: string; showLabel?: string; }; const PasswordInput = ({ className, hideLabel = "Hide password", ref: reference, showLabel = "Show password", ...props }: PasswordInputProps & { ref?: React.Ref<HTMLInputElement> }) => { const [visible, setVisible] = React.useState(false); return ( <div className="relative"> <input className={cn( "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 pr-10 text-base ring-offset-background 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 md:text-sm", className, )} ref={reference} type={visible ? "text" : "password"} {...props} /> <button aria-label={visible ? hideLabel : showLabel} className="absolute inset-y-0 right-0 flex items-center justify-center px-3 text-muted-foreground transition-colors hover:text-foreground" onClick={() => { setVisible((previous) => !previous); }} type="button" > {visible ? <EyeOff className="size-4" /> : <Eye className="size-4" />} </button> </div> ); }; PasswordInput.displayName = "PasswordInput"; export { PasswordInput };

Stories

Explorez chaque variante et etat dans le Storybook interactif :

Apercu

Basculez entre clair et sombre pour inspecter l'apercu Storybook integre.

Dependances

  • @vllnt/ui@^0.3.0