> ## Documentation Index
> Fetch the complete documentation index at: https://araf.badr.co.id/llms.txt
> Use this file to discover all available pages before exploring further.

# Toast

> A brief, auto-dismissing notification that appears at the edge of the screen to confirm actions or display system messages.

## Overview

<div style={{display:"flex",flexDirection:"column",gap:"8px",padding:"28px 24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb",maxWidth:"360px"}}>
  <div style={{background:"#fff",border:"1px solid #E4E4E7",borderRadius:"8px",padding:"12px 16px",display:"flex",alignItems:"flex-start",gap:"12px",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.07)"}}>
    <span style={{fontSize:"16px",marginTop:"1px"}}>🔔</span>

    <div style={{flex:1}}>
      <div style={{fontSize:"14px",fontWeight:600,color:"#18181B",fontFamily:"Inter,sans-serif"}}>Settings saved</div>
    </div>

    <span style={{color:"#A1A1AA",fontSize:"16px",cursor:"pointer",flexShrink:0}}>✕</span>
  </div>

  <div style={{background:"#ECFDF3",border:"1px solid #ABEFC6",borderRadius:"8px",padding:"12px 16px",display:"flex",alignItems:"flex-start",gap:"12px",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.07)"}}>
    <span style={{color:"#027A48",fontSize:"16px",marginTop:"1px"}}>✓</span>

    <div style={{flex:1}}>
      <div style={{fontSize:"14px",fontWeight:600,color:"#027A48",fontFamily:"Inter,sans-serif"}}>Payment successful</div>
      <div style={{fontSize:"13px",color:"#027A48",fontFamily:"Inter,sans-serif",marginTop:"2px"}}>Receipt sent to your email.</div>
    </div>

    <span style={{color:"#027A48",fontSize:"16px",cursor:"pointer",flexShrink:0,opacity:0.6}}>✕</span>
  </div>

  <div style={{background:"#FFFAEB",border:"1px solid #FEC84B",borderRadius:"8px",padding:"12px 16px",display:"flex",alignItems:"flex-start",gap:"12px",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.07)"}}>
    <span style={{color:"#B54708",fontSize:"16px",marginTop:"1px"}}>⚠</span>

    <div style={{flex:1}}>
      <div style={{fontSize:"14px",fontWeight:600,color:"#B54708",fontFamily:"Inter,sans-serif"}}>Storage almost full</div>
      <div style={{fontSize:"13px",color:"#B54708",fontFamily:"Inter,sans-serif",marginTop:"2px"}}>Free up space to continue syncing.</div>
    </div>

    <span style={{color:"#B54708",fontSize:"16px",cursor:"pointer",flexShrink:0,opacity:0.6}}>✕</span>
  </div>

  <div style={{background:"#FEF3F2",border:"1px solid #FECDCA",borderRadius:"8px",padding:"12px 16px",display:"flex",alignItems:"flex-start",gap:"12px",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.07)"}}>
    <span style={{color:"#B42318",fontSize:"16px",marginTop:"1px"}}>✕</span>

    <div style={{flex:1}}>
      <div style={{fontSize:"14px",fontWeight:600,color:"#B42318",fontFamily:"Inter,sans-serif"}}>Upload failed</div>
      <div style={{fontSize:"13px",color:"#B42318",fontFamily:"Inter,sans-serif",marginTop:"2px"}}>The file size exceeds the 10 MB limit.</div>
    </div>

    <span style={{color:"#B42318",fontSize:"16px",cursor:"pointer",flexShrink:0,opacity:0.6}}>✕</span>
  </div>
</div>

**Toast** is a non-blocking notification triggered by user actions or system events. It auto-dismisses after a timeout (default 4s) and supports semantic variants. Multiple toasts stack when active.

***

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npm install @araf-ds/core
  ```

  ```bash yarn theme={null}
  yarn add @araf-ds/core
  ```

  ```bash pnpm theme={null}
  pnpm add @araf-ds/core
  ```
</CodeGroup>

***

## Setup

Add `<ToastProvider>` and `<Toaster>` to your app root once:

```tsx theme={null}
// main.tsx or _app.tsx
import { ToastProvider, Toaster } from "@araf-ds/core"

function App() {
  return (
    <ToastProvider>
      <YourApp />
      <Toaster position="bottom-right" />
    </ToastProvider>
  )
}
```

***

## Usage

```tsx theme={null}
import { toast } from "@araf-ds/core"

function SaveButton() {
  return (
    <Button onClick={() => toast({ title: "Changes saved" })}>
      Save
    </Button>
  )
}
```

***

## Variants

### Default

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{background:"#fff",border:"1px solid #E4E4E7",borderRadius:"8px",padding:"12px 16px",display:"flex",alignItems:"center",gap:"12px",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.07)",maxWidth:"320px"}}>
    <span style={{fontSize:"16px"}}>🔔</span>
    <div style={{flex:1,fontSize:"14px",fontWeight:600,color:"#18181B",fontFamily:"Inter,sans-serif"}}>Settings saved</div>
    <span style={{color:"#A1A1AA",fontSize:"14px",cursor:"pointer"}}>✕</span>
  </div>
</div>

```tsx theme={null}
toast({ title: "Settings saved" });
```

### With Description

```tsx theme={null}
toast({
  title: "Profile updated",
  description: "Your changes have been saved.",
});
```

### Success

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{background:"#ECFDF3",border:"1px solid #ABEFC6",borderRadius:"8px",padding:"12px 16px",display:"flex",alignItems:"flex-start",gap:"12px",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.07)",maxWidth:"320px"}}>
    <span style={{color:"#027A48",fontSize:"16px",marginTop:"1px"}}>✓</span>

    <div style={{flex:1}}>
      <div style={{fontSize:"14px",fontWeight:600,color:"#027A48",fontFamily:"Inter,sans-serif"}}>Payment successful</div>
      <div style={{fontSize:"13px",color:"#027A48",fontFamily:"Inter,sans-serif",marginTop:"2px"}}>Receipt sent to your email.</div>
    </div>

    <span style={{color:"#027A48",fontSize:"14px",cursor:"pointer",opacity:0.6}}>✕</span>
  </div>
</div>

```tsx theme={null}
toast({
  variant: "success",
  title: "Payment successful",
  description: "Receipt sent to your email.",
});
```

### Warning

```tsx theme={null}
toast({
  variant: "warning",
  title: "Storage almost full",
  description: "Free up space to continue syncing.",
});
```

### Error

```tsx theme={null}
toast({
  variant: "error",
  title: "Upload failed",
  description: "The file size exceeds the 10 MB limit.",
});
```

### With Action

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{background:"#fff",border:"1px solid #E4E4E7",borderRadius:"8px",padding:"12px 16px",display:"flex",alignItems:"center",gap:"12px",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.07)",maxWidth:"320px"}}>
    <span style={{fontSize:"16px"}}>🔔</span>
    <div style={{flex:1,fontSize:"14px",fontWeight:600,color:"#18181B",fontFamily:"Inter,sans-serif"}}>Message deleted</div>
    <button style={{padding:"4px 10px",borderRadius:"6px",border:"1px solid #D4D4D8",background:"#fff",color:"#52525B",fontSize:"12px",fontWeight:500,fontFamily:"Inter,sans-serif",cursor:"pointer",flexShrink:0}}>Undo</button>
    <span style={{color:"#A1A1AA",fontSize:"14px",cursor:"pointer"}}>✕</span>
  </div>
</div>

```tsx theme={null}
toast({
  title: "Message deleted",
  action: (
    <ToastAction altText="Undo" onClick={handleUndo}>
      Undo
    </ToastAction>
  ),
});
```

***

## API Reference

### toast()

<ParamField path="title" type="string">
  Primary notification message (required).
</ParamField>

<ParamField path="description" type="string">
  Supporting description shown below the title.
</ParamField>

<ParamField path="variant" type="string" default="default">
  Semantic color variant. Values: `default` · `success` · `warning` · `error` · `info`
</ParamField>

<ParamField path="duration" type="number" default="4000">
  Auto-dismiss delay in milliseconds.
</ParamField>

<ParamField path="action" type="ToastActionElement">
  Optional action element (e.g. an Undo button).
</ParamField>

### Toaster

<ParamField path="position" type="string" default="bottom-right">
  Stack position on screen. Values: `top-left` · `top-center` · `top-right` · `bottom-left` · `bottom-center` · `bottom-right`
</ParamField>

***

## Accessibility

* Toast uses `role="status"` (or `role="alert"` for error variant) so screen readers announce it
* `aria-live="polite"` is used for non-critical toasts; `aria-live="assertive"` for errors
* Auto-dismiss is paused when the user hovers or focuses the toast
* Action buttons inside toasts are keyboard-navigable
* Dismiss button has an `aria-label="Close"` for screen readers

***

## Do's & Don'ts

<CardGroup cols={2}>
  <Card title="Do" icon="check" iconType="solid" color="#16A34A">
    * Use Toast for transient feedback after user actions (save, delete, upload)
    * Keep the title short — one sentence or fewer
    * Include an action when the user may want to undo
    * Use `variant="error"` for failures that need immediate attention
  </Card>

  <Card title="Don't" icon="xmark" iconType="solid" color="#DC2626">
    * Don't use Toast for persistent alerts — use Alert component instead
    * Don't stack more than 3 toasts simultaneously
    * Don't use Toast for information that requires a user decision — use Modal
    * Don't make the duration too short for toasts with descriptions (use ≥5s)
  </Card>
</CardGroup>
