Oddmash UI
모든 컴포넌트

토스트 프로바이더

독립적인 알림, 만료, 닫기를 관리합니다.

사용법

제품 화면에 ToastProvider를 한 번 렌더링하고 실제 결과가 나온 뒤 useToast의 showToast를 호출하세요. 표시 중인 알림이 가득 차면 자리가 생길 때까지 새 알림이 대기합니다.

접근성

성공 확인은 일반 알림으로, 오류는 경고로 알리되 표시 시 포커스를 옮기지 않습니다. 호버 또는 포커스 중에는 만료를 일시 중지하고 닫으면 남은 알림이나 기존 컨트롤로 포커스를 복원합니다.

속성타입기본값
maxVisiblenumber4
dismissLabelstringDismiss notification
showToast(options)ToastNotification → stringRequired title
dismissToast(id)string → voidNone
duration (notification)number | null3000; important states persist
const Controls = () => {
  const { showToast } = useToast();
  return (
    <div>
      <Button onClick={() => showToast({ title: 'Project saved', description: 'Your changes are ready.', tone: 'success' })}>
        Show saved notification
      </Button>
      <Button variant="secondary" onClick={() => showToast({ title: 'Save failed', description: 'Your changes could not be synchronized. Check your network connection and retry when you are ready.', tone: 'error' })}>
        Show error notification
      </Button>
    </div>
  );
};

<ToastProvider maxVisible={2}>
  <Controls />
</ToastProvider>

인터랙티브 문서