Alert (알림)
상태 표시와 함께 중요한 메시지나 알림을 사용자에게 보여주는 컴포넌트예요. 정보성 피드백이 필요할 때 사용해요.
출처: HeroUI Alert
본문
사용법 (Usage)
import { Alert } from '@heroui/react';
{"demo": "alert-basic"}
구조 (Anatomy)
import { Alert } from '@heroui/react';
export default () => (
<Alert>
<Alert.Indicator />
<Alert.Content>
<Alert.Title />
<Alert.Description />
</Alert.Content>
</Alert>
)
커스터마이징 (Customization)
Tailwind CSS
{"demo": "alert-custom-styles"}
Global CSS
Alert 컴포넌트의 클래스를 커스터마이징하려면 @layer components 지시어를 사용할 수 있어요.
자세히 알아보기.
@layer components {
.alert {
@apply rounded-2xl shadow-lg;
}
.alert__title {
@apply font-bold text-lg;
}
.alert--danger {
@apply border-l-4 border-red-600;
}
}
스타일링 참조 (Styling Reference)
HeroUI는 BEM 방법론을 따라 컴포넌트 변형과 상태를 재사용하고 커스터마이징하기 쉽게 만들어요.
CSS 클래스 (CSS Classes)
Alert 컴포넌트는 다음 CSS 클래스를 사용해요 (소스 스타일 보기):
기본 클래스 (Base Classes) [!toc]
.alert- 알림 기본 컨테이너.alert__indicator- 아이콘/표시 컨테이너.alert__content- 제목과 설명을 감싸는 콘텐츠 래퍼.alert__title- 알림 제목 텍스트.alert__description- 알림 설명 텍스트
상태 변형 클래스 (Status Variant Classes) [!toc]
.alert--default- 기본 회색 상태.alert--accent- 강조 파란색 상태.alert--success- 성공 초록색 상태.alert--warning- 경고 노랑/주황 상태.alert--danger- 위험 빨간색 상태
상호작용 상태 (Interactive States)
Alert 컴포넌트는 기본적으로 정보성이라 기본 컴포넌트에는 상호작용 상태가 없어요. 하지만 버튼이나 닫기 버튼 같은 상호작용 요소를 내부에 넣을 수는 있어요.
API 참조 (API Reference)
Alert
| Prop | Type | Default | Description |
|---|---|---|---|
status |
"default" | "accent" | "success" | "warning" | "danger" |
"default" |
The visual status of the alert |
className |
string |
- | Additional CSS classes |
children |
ReactNode |
- | The alert content |
Alert.Indicator
| Prop | Type | Default | Description |
|---|---|---|---|
className |
string |
- | Additional CSS classes |
children |
ReactNode |
- | Custom indicator icon (defaults to status icon) |
Alert.Content
| Prop | Type | Default | Description |
|---|---|---|---|
className |
string |
- | Additional CSS classes |
children |
ReactNode |
- | Content (typically Title and Description) |
Alert.Title
| Prop | Type | Default | Description |
|---|---|---|---|
className |
string |
- | Additional CSS classes |
children |
ReactNode |
- | The alert title text |
Alert.Description
| Prop | Type | Default | Description |
|---|---|---|---|
className |
string |
- | Additional CSS classes |
children |
ReactNode |
- | The alert description text |