ConfirmationDialog 접근성
ConfirmationDialog를 접근성 있게 만드는 방법을 설명합니다. 명확한 타이틀과 맥락에 맞는 버튼 라벨, danger 스타일링, 키보드 내비게이션, 포커스 관리, 화면 낭독기 지원, 자동 ARIA 속성, 보조 기술 테스트 지침을 다룹니다.
출처: 문서
본문
ConfirmationDialog는 사용자 액션을 확인하는 데 사용되는 특화된 대화상자 컴포넌트입니다. 잠재적으로 파괴적이거나 중요한 액션을 확인하거나 취소하도록 사용자에게 묻는 간단한 방법을 제공합니다.
명확하고 설명적인 타이틀 사용 (Use clear, descriptive titles)
ConfirmationDialog의 타이틀은 확인 중인 액션을 명확히 설명해야 합니다. 사용자가 어떤 일이 일어날지 이해하도록 돕는 구체적인 언어를 사용하세요.
// Good: Specific and clear
<ConfirmationDialog title="Delete repository?">
This action cannot be undone. This will permanently delete the "my-repo" repository.
</ConfirmationDialog>
// Avoid: Vague or generic
<ConfirmationDialog title="Are you sure?">
This action cannot be undone.
</ConfirmationDialog>
적절한 버튼 라벨 사용 (Use appropriate button labels)
버튼 라벨은 액션 지향적이고 맥락에 맞아야 합니다. 가능하면 "OK"나 "Yes/No" 같은 일반적인 라벨을 피하세요.
// Good: Action-specific labels
<ConfirmationDialog
title="Delete repository?"
confirmButtonContent="Delete repository"
cancelButtonContent="Cancel"
>
This action cannot be undone.
</ConfirmationDialog>
// Avoid: Generic labels
<ConfirmationDialog
title="Delete repository?"
confirmButtonContent="Yes"
cancelButtonContent="No"
>
This action cannot be undone.
</ConfirmationDialog>
파괴적 액션에는 danger 스타일링 사용 (Use danger styling for destructive actions)
확인이 파괴적이거나 되돌릴 수 없는 액션을 포함할 때는 danger 버튼 유형을 사용해 시각적인 강조를 제공하세요.
<ConfirmationDialog title="Delete repository?" confirmButtonContent="Delete repository" confirmButtonType="danger">
This action cannot be undone.
</ConfirmationDialog>
키보드 내비게이션 (Keyboard navigation)
ConfirmationDialog는 완전한 키보드 내비게이션을 지원합니다.
Tab: 취소와 확인 버튼 사이를 탐색합니다Shift + Tab: 버튼 사이를 뒤로 탐색합니다Enter: 포커스된 버튼을 활성화합니다Escape: 대화상자를 닫습니다(취소 클릭과 동일)
포커스 관리 (Focus management)
- 대화상자가 열리면 포커스가 자동으로 적절한 버튼에 배치됩니다.
- 위험한 액션(
confirmButtonType="danger")의 경우 Cancel 버튼에 포커스가 배치됩니다. - 위험하지 않은 액션의 경우 Confirm 버튼에 포커스가 배치됩니다.
- 대화상자가 닫히면 포커스가 그것을 트리거한 요소로 돌아갑니다.
화면 낭독기 지원 (Screen reader support)
- 적절한 화면 낭독기 선언을 위해
alertdialog역할을 사용합니다. - 타이틀이 대화상자의 접근 가능한 이름 역할을 합니다.
- 버튼 라벨이 화면 낭독기 사용자에게 명확하게 선언됩니다.
- 대화상자 콘텐츠가 확인 액션에 대한 맥락을 제공합니다.
ARIA 속성 (ARIA attributes)
ConfirmationDialog는 적절한 ARIA 속성을 자동으로 적용합니다.
role="alertdialog": 이 모달 대화상자가 사용자 응답을 필요로 함을 나타냅니다aria-labelledby: 대화상자 타이틀을 가리킵니다aria-describedby: 추가 맥락을 위해 대화상자 콘텐츠를 가리킵니다aria-modal="true": 대화상자가 모달임을 나타냅니다
구현 지침 (Implementation guidelines)
항상 맥락 제공 (Always provide context)
사용자가 정보에 입각한 결정을 내릴 수 있도록 대화상자 콘텐츠에 충분한 정보를 포함하세요.
<ConfirmationDialog title="Delete 5 selected items?">
This will permanently delete the selected files. This action cannot be undone.
</ConfirmationDialog>
결과 고려하기 (Consider the consequences)
중대한 결과를 초래하는 액션의 경우 추가 확인을 요구하거나 가능하면 실행 취소(undo) 기능을 제공하는 것을 고려하세요.
보조 기술로 테스트 (Test with assistive technology)
항상 ConfirmationDialog 구현을 화면 낭독기와 키보드 전용 내비게이션으로 테스트하여 접근성 준수를 확인하세요.
더 알아보기 (Learn more)
- ConfirmationDialog 컴포넌트: 기본 사용법과 props를 확인하세요.
- ConfirmationDialog 가이드라인: 사용·패턴·콘텐츠 가이드라인을 살펴보세요.
- Primer 접근성 원칙: Primer의 접근성 접근 방식을 둘러보세요.