Default
import { PixelPasswordInput } from '@pxlkit/ui-kit';
export function Default() {
return <PixelPasswordInput label="Password" placeholder="Enter password" />;
}Password text field with an inline show/hide toggle that swaps the input type between password and text.
v-model (Vue), ngModel or reactive forms (Angular)import { PixelPasswordInput } from '@pxlkit/ui-kit';| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Floating label rendered above the input shell. |
hint | string | — | Helper text shown below the field. Hidden when error is set. |
error | string | — | Error message shown below the field; flips visual state to invalid. |
tone | 'green' | 'cyan' | 'gold' | 'red' | 'purple' | 'pink' | 'neutral' | 'neutral' | Visual tone for focus ring + border emphasis. Default: 'neutral'. |
size | 'sm' | 'md' | 'lg' | 'md' | Field height token. Default: 'md'. |
surface | 'pixel' | 'linear' | — | Surface variant. Inherits from PxlKitSurfaceProvider when omitted. |
toggleLabels | [string, string] | ['Show', 'Hide'] | Text for the visibility toggle, in [showLabel, hideLabel] form. |
Also takes the native attributes and event handlers of <input> (InputHTMLAttributes<HTMLInputElement>), except type.
ref points to <input>.
WCAG target: 2.1 AA
textboxbuttonThe visibility toggle is a real <button type="button"> with an aria-label that mirrors the current state, and exposes aria-pressed so screen readers announce whether the password is currently visible. The input sets aria-invalid when an error is present, and its aria-describedby points at the hint/error message while one shows, after any ids you pass.
| Key | Action | When |
|---|---|---|
| Tab | Moves focus into the password field; the visibility toggle is intentionally skipped (tabIndex=-1) so keyboard flow stays on the text field. | — |
| Enter | Submits the enclosing form, matching native password input behavior. | — |
import { PixelPasswordInput } from '@pxlkit/ui-kit';
export function Default() {
return <PixelPasswordInput label="Password" placeholder="Enter password" />;
}import { PixelPasswordInput } from '@pxlkit/ui-kit';
export function Default() {
return <PixelPasswordInput label="Password" placeholder="Enter password" />;
}import { PixelPasswordInput } from '@pxlkit/ui-kit';
export function WithHint() {
return (
<PixelPasswordInput
label="Password"
hint="At least 8 characters, mixing letters and numbers."
placeholder="Enter password"
/>
);
}import { PixelPasswordInput } from '@pxlkit/ui-kit';
export function WithError() {
return (
<PixelPasswordInput
label="Password"
error="Password is too short."
defaultValue="abc"
/>
);
}import { PixelPasswordInput } from '@pxlkit/ui-kit';
export function Tones() {
return (
<div className="space-y-3">
<PixelPasswordInput label="Neutral" tone="neutral" placeholder="Password" />
<PixelPasswordInput label="Green" tone="green" placeholder="Password" />
<PixelPasswordInput label="Cyan" tone="cyan" placeholder="Password" />
<PixelPasswordInput label="Gold" tone="gold" placeholder="Password" />
<PixelPasswordInput label="Red" tone="red" placeholder="Password" />
<PixelPasswordInput label="Purple" tone="purple" placeholder="Password" />
<PixelPasswordInput label="Pink" tone="pink" placeholder="Password" />
</div>
);
}import { PixelPasswordInput } from '@pxlkit/ui-kit';
export function Sizes() {
return (
<div className="space-y-3">
<PixelPasswordInput label="Small" size="sm" placeholder="Password" />
<PixelPasswordInput label="Medium" size="md" placeholder="Password" />
<PixelPasswordInput label="Large" size="lg" placeholder="Password" />
</div>
);
}import { PixelPasswordInput } from '@pxlkit/ui-kit';
export function Surfaces() {
return (
<div className="space-y-3">
<PixelPasswordInput label="Pixel surface" surface="pixel" placeholder="Password" />
<PixelPasswordInput label="Linear surface" surface="linear" placeholder="Password" />
</div>
);
}import { PixelPasswordInput } from '@pxlkit/ui-kit';
export function Disabled() {
return (
<PixelPasswordInput
label="Password"
disabled
defaultValue="cannot-edit"
/>
);
}import { PixelPasswordInput } from '@pxlkit/ui-kit';
export function CustomToggleLabels() {
return (
<PixelPasswordInput
label="Password"
toggleLabels={['View', 'Mask']}
placeholder="Enter password"
/>
);
}import { useState } from 'react';
import { PixelPasswordInput } from '@pxlkit/ui-kit';
export function Controlled() {
const [value, setValue] = useState('');
return (
<PixelPasswordInput
label="Password"
value={value}
onChange={(e) => setValue(e.target.value)}
hint={`Length: ${value.length}`}
/>
);
}import { PixelPasswordInput } from '@pxlkit/ui-kit';
export function Uncontrolled() {
return (
<PixelPasswordInput
label="Password"
defaultValue="hunter2"
/>
);
}