PasswordInput
The PasswordInput component is designed to securely collect password information from users. It features built-in security measures and user-friendly enhancements to ensure both safety and ease of use. This component is an essential part of any form where sensitive data is required.
Examples
A basic
<PasswordInput label="Password" />
With icon on the left
<PasswordInput label="Train password" startElement={<TrainOutline24Icon />} />
Controlled field with validation
() => { const [password, setPassword] = React.useState(""); return ( <PasswordInput label="Password" value={password} invalid={password !== "Tut tut"} errorText="Wrong password!" onChange={e => setPassword(e.target.value)} /> ); }
Different variants
<Stack gap={3}> <PasswordInput label="Core" /> <PasswordInput label="Floating" variant="floating" /> </Stack>
Guidelines
Key Features
- Secure Entry: Masks user input to protect sensitive information from onlookers.
- Visibility Toggle: Allows users to toggle password visibility for convenience during entry.
- Validation Feedback: Provides real-time feedback on password strength and validation requirements.
- Accessibility: Fully accessible to users with disabilities, ensuring compliance with accessibility standards.
Usage
The PasswordInput component should be used in any scenario where a user is required to input a password. It is ideal for login forms, account creation, password updates, and other security-sensitive fields.
By incorporating the PasswordInput component into your application, you can ensure a secure and user-friendly experience for your users.
Code
<PasswordInput />
import { PasswordInput } from "@vygruppen/spor-react";
A password input, with a "show/hide" feature
Props
Name | Type | Required? | Description |
|---|---|---|---|
onVisibleChange | (visible: boolean) => void | Callback invoked when the visibility state changes. | |
defaultVisible | boolean | Default visibility state of the password input | |
visible | boolean | Controlled visibility state |
<Input />
import { Input } from "@vygruppen/spor-react";
Props
Name | Type | Required? | Description |
|---|---|---|---|
label | string | A descriptive label | |
variant | "core" | "floating" | Defaults to core. | |
startElement | React.ReactNode | Use the 24px icons | |
endElement | React.ReactNode | Use the 24px icons | |
disabled | boolean | ||
invalid | boolean | ||
errorText | React.ReactNode | Display error text for the component | |
readonly | boolean | ||
required | boolean | ||
helperText | React.ReactNode | Display helper text for the input |