Toast
Toast는 방금 실행한 동작의 결과를 화면 한쪽에 잠깐 보여 주는 알림입니다. 주로 저장 완료, 업로드 실패처럼 짧게 알리고 지나가도 되는 내용에 사용됩니다. 실행 취소 같은 후속 동작 버튼을 함께 둘 수 있으며, 화면에 띄우고 없애는 시점은 사용하는 쪽에서 정합니다.
State
Examples
화면 고정 위치, 쌓기, 자동 닫힘은 AToast에 없다. 아래처럼 쓰는 쪽에서 감싸서 만든다.
vue
<Teleport to="body">
<TransitionGroup
tag="div"
class="fixed right-6 bottom-6 z-(--z-modal) flex flex-col items-end gap-3"
enter-active-class="transition-[opacity,transform] duration-(--duration-slow)"
leave-active-class="transition-[opacity,transform] duration-(--duration-base)"
enter-from-class="translate-y-4 opacity-0"
leave-to-class="translate-y-2 opacity-0"
>
<AToast v-for="t in toasts" :key="t.id" closable :title="t.title" @close="dismiss(t.id)" />
</TransitionGroup>
</Teleport>Code
vue
<script setup>
import { AToast } from '@mobigen/rnd-design-system'
function undo() {
// 실행 취소 처리
}
</script>
<template>
<AToast
title="Event has been created"
description="Sunday, December 03, 2023 at 9:00 AM"
action-label="Undo"
@action="undo"
/>
</template>Props
| 속성 | 값 |
|---|---|
title | String (필수) |
description | String |
actionLabel | String |
variant | default, info, success, warning, danger |
closable | true, false |
closeLabel | String |
width | String |
Events
| 이벤트 | 전달 값 |
|---|---|
action | 없음 |
close | 없음 |
Slots
| 슬롯 | 전달 값 |
|---|---|
default | 없음 |
Notes
- 표시용 박스다. 화면 고정 배치, 자동 사라짐, 여러 토스트 쌓기는 호출부가 구현한다.
closable은 닫기 버튼과close이벤트만 제공한다. 토스트를 숨기는 것은 호출부가 한다.