¥Password Toggle Field
一个带有内置按钮的密码输入框,用于切换值的可见性。
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
¥Anatomy
导入所有部分并将它们组合在一起。
¥Import all parts and piece them together.
¥API Reference
¥Root
包含密码切换框的所有部分。
¥Contains all the parts of a password toggle field.
¥Input
渲染包含密码值的输入框。
¥Renders a the input containing the password value.
¥Toggle
¥Slot
¥Icon
¥Examples
¥Basic usage
Slot
¥With Slot
Slot
+ render
属性¥With Slot
+ render
prop