본문으로 건너뛰기
Amineslab UI

Component

PasswordInput

비밀번호 입력과 표시 토글을 합성한 필드입니다.

Playground

옵션을 조절하며 화면과 사용 코드를 함께 확인하세요.

PC 1280px
Controls

빈 입력 안내 · 사용처의 언어와 문구로 변경

Code
import { type InputProps, PasswordInput } from '@amineslab/ui'

function PasswordExample({ autoComplete = 'current-password', placeholder = '비밀번호를 입력해 주세요', showToggle, size, ...inputProps }: {
    showToggle: boolean;
    size: string;
} & Pick<InputProps, 'opaque' | 'variant' | 'invalid' | 'disabled' | 'startAdornment' | 'endAdornment' | 'placeholder' | 'autoComplete'>) {
    const resolvedSize = size === 'xs' || size === 'sm' || size === 'lg' || size === 'xl' ? size : 'md';
    return (<PasswordInput {...inputProps} aria-label="비밀번호" autoComplete={autoComplete} placeholder={placeholder} showToggle={showToggle} size={resolvedSize}/>);
}

export default function ExamplePreview() {
  return ((<PasswordExample {...({"autoComplete":"current-password","placeholder":"비밀번호를 입력해 주세요","opaque":false,"variant":"filled","invalid":false,"disabled":false,"startAdornment":"","endAdornment":"","showToggle":true,"size":"md"} as const)} variant={"filled"}/>))
}

Props

@amineslab/ui에서 PasswordInput를 가져옵니다.

import { PasswordInput } from '@amineslab/ui'

PasswordInput

기본 Input 속성과 보이기 토글을 전달합니다.

NameTypeDefaultDescription
placeholderstring-빈 입력 안내를 사용처의 언어·어투로 덮어씁니다. 빈 문자열로 숨길 수 있습니다.
showTogglebooleantrue표시/숨기기 버튼을 렌더합니다.
size'xs' | 'sm' | 'md' | 'lg' | 'xl''md'입력과 토글의 밀도입니다.
autoCompletestring-브라우저 비밀번호 자동 완성 정책입니다.
invalidbooleanfalse오류 테두리를 표시하며 focus·open 상태에서도 유지합니다. aria-invalid도 함께 전달합니다.
variant'filled' | 'outline'filled공통 필드 표면 표현입니다. focus·hover는 중립 elevation을 사용합니다.
opaquebooleanfalseelevation 레이어 아래 불투명한 테마 바탕을 추가합니다. hover·focus·invalid 표현은 유지합니다.
startAdornment / endAdornmentReactNode | IconComponent-Input과 동일하게 아이콘 컴포넌트·문자열·ReactNode를 받습니다. PasswordInput의 표시 버튼은 오른쪽 슬롯과 함께 배치됩니다.

Examples

자주 쓰는 조합을 살펴보고, 필요한 예시의 코드를 펼쳐 확인하세요.

공통 필드 표면

variant는 filled·outline 표현을, opaque는 elevation 아래의 불투명 바탕을 정합니다. focus와 hover는 중립 elevation을 사용하고 invalid 테두리는 포커스 중에도 유지합니다. NumberInput·PhoneInput·PasswordInput은 Input의 아이콘·문자열·ReactNode 슬롯을 상속합니다. SelectField에서는 같은 표면 props를 직접 지정하거나 triggerProps로 세부 설정할 수 있습니다.

투명 바탕
확인
불투명 바탕
확인
Outline + 불투명 바탕
확인
<PasswordInput defaultValue="password" endAdornment="확인" />

<PasswordInput defaultValue="password" endAdornment="확인" opaque />

<PasswordInput defaultValue="password" endAdornment="확인" variant="outline" opaque />

표시 토글

토글은 키보드로도 실행하고 aria-pressed 상태를 제공합니다.

import { type InputProps, PasswordInput } from '@amineslab/ui'

function PasswordExample({ autoComplete = 'current-password', placeholder = '비밀번호를 입력해 주세요', showToggle, size, ...inputProps }: {
    showToggle: boolean;
    size: string;
} & Pick<InputProps, 'opaque' | 'variant' | 'invalid' | 'disabled' | 'startAdornment' | 'endAdornment' | 'placeholder' | 'autoComplete'>) {
    const resolvedSize = size === 'xs' || size === 'sm' || size === 'lg' || size === 'xl' ? size : 'md';
    return (<PasswordInput {...inputProps} aria-label="비밀번호" autoComplete={autoComplete} placeholder={placeholder} showToggle={showToggle} size={resolvedSize}/>);
}

export default function ExamplePreview() {
  return (<PasswordExample showToggle size="md"/>)
}

PasswordField로 사용하기

PasswordField는 기본 입력에 label·required·description·error를 함께 제공합니다. FormStack 안에 직접 넣으며 FormField로 다시 감싸지 않습니다.

라벨·설명·필수 표시를 Field가 함께 처리합니다.

import { useState } from 'react'

import { PasswordField } from '@amineslab/ui'

const fieldDescription = '라벨·설명·필수 표시를 Field가 함께 처리합니다.';

function PasswordFieldExample() {
    const [value, setValue] = useState('');
    return (<PasswordField label="비밀번호" description={fieldDescription} required value={value} onValueChange={setValue}/>);
}

export default function ExamplePreview() {
  return (<PasswordFieldExample />)
}

사용 기준

권장하는 사용
  • 기본 토글은 필드 높이를 채우는 44px 터치 영역을 가지며 aria-pressed로 상태를 알립니다.
피해야 할 사용
  • 겉모양만으로 사용을 결정하지 마세요.
  • 의미와 키보드 동작, 모바일에서의 흐름을 함께 확인하세요.

접근성

화면에 맞는 이름을 제공하고, 키보드만으로 작업을 마칠 수 있는지 확인하세요.

  • Enter / Space: 표시 토글 버튼을 실행합니다.