Alert
아이콘, 제목, 설명을 정렬하는 조합형 Alert입니다. default, success, destructive 변형이 있으며 모든 변형이 색상 외에 테두리와 텍스트 대비를 함께 사용합니다.
@neumorphism-ui/alert미리보기
새 Registry 버전
로컬 소스를 다시 설치하면 변경점을 확인할 수 있습니다.
동기화 완료
56개 컴포넌트가 현재 프로젝트와 일치합니다.
토큰을 찾을 수 없습니다
globals.css에 base 항목을 먼저 설치해 주세요.
설치
설치: alert
npx shadcn@latest add @neumorphism-ui/alertCLI가 npm 의존성, base 토큰, utils와 컴포넌트 소스를 순서대로 확인하고 설치합니다.
Registry를 처음 사용한다면 namespace 설정 을 먼저 완료하세요.
사용법
Import
Alert import 코드
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"Example
Alert 사용 코드
<Alert variant="success">
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"><path d="m5 12 4 4L19 6" /></svg>
<AlertTitle>저장했습니다</AlertTitle>
<AlertDescription>
변경 사항이 모든 팀원에게 반영되었습니다.
</AlertDescription>
</Alert>API 레퍼런스
| 컴포넌트 | 속성 | 타입 | 기본값 | 설명 |
|---|---|---|---|---|
Alert | variant | "default" | "success" | "destructive" | "default" | 메시지의 의미와 시각적 상태를 선택합니다. |
Alert | children | React.ReactNode | — | 아이콘, AlertTitle, AlertDescription을 배치합니다. |
Alert | className | string | — | 기본 표면 스타일을 확장합니다. |
접근성
- 01
Alert는 role=alert를 사용하므로 동적으로 나타나는 중요한 메시지에 적합합니다.
- 02
페이지 로드 때부터 보이는 일반 안내에는 role=alert의 즉시 읽기가 불필요할 수 있으므로 role을 덮어쓰거나 다른 컨테이너를 사용합니다.
- 03
장식 아이콘에는 aria-hidden=true를 지정하고 의미는 제목과 설명 텍스트로도 전달합니다.