Password
"use client";
import { Field, Password } from "@cherry-design-system/react";
export function SignInPassword() {
return (
<Field label="Password">
<Password name="password" autoComplete="current-password" />
</Field>
);
}A password input with a show and hide toggle. It is built on Input, so it shares its sizes, leading icon and error state.
Examples
With a leading icon
"use client";
import { Field, Password } from "@cherry-design-system/react";
import { Lock } from "lucide-react";
export function NewPassword() {
return (
<Field label="New password" hint="At least 12 characters.">
<Password autoComplete="new-password" leadingIcon={<Lock />} minLength={12} />
</Field>
);
}Controlled visibility
"use client";
import { useState } from "react";
import { Field, Password } from "@cherry-design-system/react";
export function ApiSecret() {
const [visible, setVisible] = useState(false);
return (
<Field label="Client secret">
<Password
visible={visible}
onVisibleChange={setVisible}
toggleLabel="Show client secret"
readOnly
defaultValue="cs_9f2a7c"
/>
</Field>
);
}Properties
Input size. Defaults to "md".
Controlled visibility of the value.
Initial visibility when uncontrolled. Defaults to false.
Called when the toggle is pressed.
Name of the show/hide button. It is a toggle, so aria-pressed carries the state and the name stays the same. Defaults to "Show password".
Icon before the text.
Error state; set automatically inside a <Field error>.
Class for the outer wrapper (className goes to the <input>).
Accepts the other Input props and native <input> attributes except type and suffix. The ref goes to the <input>.
Styling
Root class cherry-password (on the Input wrapper) with data-size (sm, md, lg) and states data-invalid, data-disabled. The toggle is cherry-password__toggle with aria-pressed; the eye glyph parts are cherry-password__icon, __eye, __lid, __pupil and __lashes. The Input classes (cherry-input, cherry-input__control) apply too.
Accessibility
The reveal button is labelled (toggleLabel) and exposes aria-pressed. Label the field like Input, with Field or aria-label. Set autoComplete to current-password or new-password so password managers can help.