Updated
Password Peek
NewCustomize
Reveal duration0.35s
Radius12px
Installation
npx shadcn@latest add https://uibrik.com/r/password-peek.jsonInstall the packages
npm install motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/password-peek/password-peek.tsx"use client"; import { motion, useReducedMotion } from "motion/react"; import { useEffect, useId, useLayoutEffect, useRef, useState, type InputHTMLAttributes } from "react"; import { cn } from "@/lib/utils"; const EASE_OUT: [number, number, number, number] = [0.23, 1, 0.32, 1]; export type PasswordPeekProps = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "defaultValue" | "onChange" | "size"> & { /** Controlled value. */ value?: string; /** Value on mount when uncontrolled. */ defaultValue?: string; onValueChange?: (value: string) => void; /** Controlled visibility. */ visible?: boolean; /** Visibility on mount when uncontrolled. */ defaultVisible?: boolean; onVisibleChange?: (visible: boolean) => void; /** Label above the field. Leave empty to hide it; it stays as the accessible name. */ label?: string; /** Seconds the whole left-to-right reveal may take, however long the password. */ revealDuration?: number; /** Corner radius in px. */
Adds the files to
components/uibrik/password-peek and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/password-peek.Usage
import { PasswordPeek } from "@/components/uibrik/password-peek/password-peek";<PasswordPeek label="Password" placeholder="Enter password" defaultValue="sunset-harbor-42" revealDuration={0.35} radius={12} defaultVisible={false} // value="…" // onValueChange={(value) => {}} // visible={false} // onVisibleChange={(visible) => {}}/>Where to use Password Peek
Sign-in and sign-up
The left-to-right reveal makes it obvious the password is now showing, even at a glance.
Pairs with Auth Forms and Password Strength
Wi-Fi and device setup
Long generated passwords are easier to check against a label when they appear in order.
Secrets in settings
The same peek works for tokens and keys a user needs to read back once.
Pairs with API Keys and Settings Page
Props
PasswordPeek- label
- Type string
- "Password"
- Label above the field. Empty hides it but keeps it as the accessible name.
- placeholder
- Type string
- "Enter password"
- Shown while empty.
- defaultValue
- Type string
- "sunset-harbor-42"
- Value on mount when uncontrolled.
- revealDuration
- Type number
- 0.35
- Longest the left-to-right reveal may take, however long the password.
- radius
- Type number
- 12
- Corner radius.
- value / onValueChange
- Type string / (value) => void
- –
- Controlled value.
- visible / onVisibleChange
- Type boolean / (visible) => void
- –
- Controlled visibility.
- defaultVisible
- Type boolean
- false
- Visibility on mount when uncontrolled.
- ...input props
- Type InputHTMLAttributes
- –
- name, autoComplete, required and the rest go to the input.
- className
- Type string
- –
- Classes for the wrapper.