A password input field with an integrated button to toggle the value's visibility.
import * as React from "react";import { unstable_PasswordToggleField as PasswordToggleField } from "radix-ui";import { EyeClosedIcon, EyeOpenIcon } from "@radix-ui/react-icons";const PasswordToggleFieldDemo = () => (<PasswordToggleField.Root><div className="Root"><PasswordToggleField.Input className="Input" /><PasswordToggleField.Toggle className="Toggle"><PasswordToggleField.Icon visible={<EyeOpenIcon />} hidden={<EyeClosedIcon />} /></PasswordToggleField.Toggle></div></PasswordToggleField.Root>);export default PasswordToggleFieldDemo;
Returns focus to the input when toggling with a pointer
Maintains button focus when toggling with keyboard or virtual navigation
Resets visibility to hidden after form submission to prevent accidental storage
Implicit accessible labeling for icon-based toggle buttons
Import all parts and piece them together.
Contains all the parts of a password toggle field.
Renders a the input containing the password value.
Slot
Slot
+ render
prop