얼럿

네 가지 심각도의 상태 메시지를 위한 손그림 스타일의 인라인 얼럿/배너입니다.

개요

Alert(배너)는 작업이나 페이지의 상태를 전달하는 인라인 메시지예요 — 정보, 성공, 경고, 위험 중 하나예요. 떠서 자동으로 사라지는 Toast와 달리 레이아웃 안에 자리 잡아요.

구조

심각도에 따른 색상 외곽선과 아이콘, 선택적 굵은 제목, 메시지, 선택적 닫기 버튼을 가진 손그림 스타일의 박스(@ghds/sketch-core)예요.

변형 및 상태

State Status Notes
Info / Success / Warning / Danger Implemented 네 가지 심각도이며 각각 고유한 색상과 아이콘을 가져요.
닫기 가능 Implemented 선택적 닫기 버튼(React/RN: onDismiss; WC: dismissible + dismiss 이벤트).

사용법

Do

  • 심각도를 메시지에 맞게 사용하세요: 확인은 success, 오류는 danger.
  • 메시지를 짧고 행동 유도형으로 유지하세요.
  • 관련 콘텐츠 근처에 배치하세요.

Don't

  • 일시적인 피드백에 Alert를 사용하지 마세요 — Toast를 사용하세요.
  • 색상에만 의존하지 마세요; 아이콘과 텍스트도 의미를 전달해요.

접근성

콘텐츠

선택적 짧은 제목과 간결한 메시지예요.

Props API

React@ghds/react

PropTypeDefaultDescription
variant'info' | 'success' | 'warning' | 'danger''info'심각도.
titleReactNode—선택적 굵은 제목.
childrenReactNode—메시지 본문.
onDismiss() => void—닫기 버튼을 렌더하고 이 함수를 호출해요.
variantLabelstring'Info' | 'Success' | 'Warning' | 'Error'심각도 아이콘의 접근 가능한 이름. 번역을 전달해서 현지화하거나 ''로 아이콘을 장식용으로 둬요.

Web Components@ghds/web-components

PropTypeDefaultDescription
variant'info' | 'success' | 'warning' | 'danger''info'심각도(reflected).
headingstring—선택적 굵은 제목.
dismissiblebooleanfalse닫기 버튼 표시.
variant-labelstring'Info' | 'Success' | 'Warning' | 'Error'심각도 아이콘의 접근 가능한 이름(프로퍼티 variantLabel). 번역을 지정해서 현지화하거나 ''로 아이콘을 장식용으로 둬요.
dismiss eventCustomEvent—닫기 버튼에서 발생해요.

React Native@ghds/react-native

PropTypeDefaultDescription
variant'info' | 'success' | 'warning' | 'danger''info'심각도.
titlestring—선택적 굵은 제목.
childrenReactNode—메시지 본문.
onDismiss() => void—닫기 버튼을 렌더하고 이 함수를 호출해요.
variantLabelstring'Info' | 'Success' | 'Warning' | 'Error'심각도 아이콘의 접근 가능한 이름. 번역을 전달해서 현지화하거나 ''로 아이콘을 장식용으로 둬요.
testIDstring—쿼리용 테스트 핸들.

코드 예시

// React — @ghds/react
import { Alert } from '@ghds/react/alert';

<Alert variant="danger" title="Error" onDismiss={() => dismiss()}>
  Something went wrong.
</Alert>;
<!-- Web Components — @ghds/web-components -->
<script type="module">
  import '@ghds/web-components/alert';
</script>
<gh-alert variant="danger" heading="Error" dismissible>Something went wrong.</gh-alert>
<script>
  // gh-alert는 `dismiss` 이벤트만 보내요. 알림을 없애는 건 직접 처리해야 해요
  document.querySelector('gh-alert').addEventListener('dismiss', (e) => e.currentTarget.remove());
</script>
// React Native — @ghds/react-native
import { Alert } from '@ghds/react-native/alert';

<Alert variant="danger" title="Error" onDismiss={() => dismiss()}>
  Something went wrong.
</Alert>;

라이브 데모

React @ghds/react

Web Components @ghds/web-components

An info message. A success message. A warning message. A danger message.