> ## 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.

# Alert

> A prominent message bar for system feedback — supports 6 semantic variants with icon, title, description, and optional action.

## Overview

<div style={{display:"flex",flexDirection:"column",gap:"10px",padding:"28px 24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{background:"#eff8ff",border:"1px solid #b2ddff",borderRadius:"8px",padding:"14px 16px",display:"flex",gap:"12px",alignItems:"flex-start"}}>
    <span style={{color:"#1570ef",fontSize:"16px",marginTop:"1px"}}>ℹ</span>
    <div><div style={{fontSize:"14px",fontWeight:600,color:"#1570ef",fontFamily:"Inter,sans-serif"}}>Tip</div><div style={{fontSize:"13px",color:"#1570ef",fontFamily:"Inter,sans-serif",marginTop:"2px"}}>You can invite up to 10 team members on the free plan.</div></div>
  </div>

  <div style={{background:"#ecfdf3",border:"1px solid #abefc6",borderRadius:"8px",padding:"14px 16px",display:"flex",gap:"12px",alignItems:"flex-start"}}>
    <span style={{color:"#027a48",fontSize:"16px",marginTop:"1px"}}>✓</span>
    <div><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>
  </div>

  <div style={{background:"#fffaeb",border:"1px solid #fec84b",borderRadius:"8px",padding:"14px 16px",display:"flex",gap:"12px",alignItems:"flex-start"}}>
    <span style={{color:"#b54708",fontSize:"16px",marginTop:"1px"}}>⚠</span>
    <div><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"}}>You have used 90% of your storage limit.</div></div>
  </div>

  <div style={{background:"#fef3f2",border:"1px solid #fecdca",borderRadius:"8px",padding:"14px 16px",display:"flex",gap:"12px",alignItems:"flex-start"}}>
    <span style={{color:"#b42318",fontSize:"16px",marginTop:"1px"}}>✕</span>
    <div><div style={{fontSize:"14px",fontWeight:600,color:"#b42318",fontFamily:"Inter,sans-serif"}}>Failed to save</div><div style={{fontSize:"13px",color:"#b42318",fontFamily:"Inter,sans-serif",marginTop:"2px"}}>There was an error saving your changes. Please try again.</div></div>
  </div>
</div>

**Alert** communicates important information to the user at the page or section level. It is non-dismissible by default and each variant automatically applies a matching icon, background, border, and text color.

***

## 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>

***

## Usage

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

export default function Example() {
  return (
    <Alert
      variant="success"
      title="Profile saved"
      description="Your changes have been saved successfully."
    />
  )
}
```

***

## Variants

Alert has **6 semantic variants** covering the full range of feedback contexts.

### Default

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{background:"#fff",border:"1px solid #e4e4e7",borderRadius:"8px",padding:"14px 16px",display:"flex",gap:"12px",alignItems:"flex-start"}}>
    <span style={{color:"#52525b",fontSize:"16px",marginTop:"1px"}}>🔔</span>
    <div><div style={{fontSize:"14px",fontWeight:600,color:"#18181b",fontFamily:"Inter,sans-serif"}}>New update available</div><div style={{fontSize:"13px",color:"#52525b",fontFamily:"Inter,sans-serif",marginTop:"2px"}}>A new version of the app is ready to install.</div></div>
  </div>
</div>

```tsx theme={null}
<Alert
  title="New update available"
  description="A new version of the app is ready to install."
/>
```

### Info

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{background:"#eff8ff",border:"1px solid #b2ddff",borderRadius:"8px",padding:"14px 16px",display:"flex",gap:"12px",alignItems:"flex-start"}}>
    <span style={{color:"#1570ef",fontSize:"16px",marginTop:"1px"}}>ℹ</span>
    <div><div style={{fontSize:"14px",fontWeight:600,color:"#1570ef",fontFamily:"Inter,sans-serif"}}>Tip</div><div style={{fontSize:"13px",color:"#1570ef",fontFamily:"Inter,sans-serif",marginTop:"2px"}}>You can invite up to 10 team members on the free plan.</div></div>
  </div>
</div>

```tsx theme={null}
<Alert
  variant="info"
  title="Tip"
  description="You can invite up to 10 team members on the free plan."
/>
```

### Success

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{background:"#ecfdf3",border:"1px solid #abefc6",borderRadius:"8px",padding:"14px 16px",display:"flex",gap:"12px",alignItems:"flex-start"}}>
    <span style={{color:"#027a48",fontSize:"16px",marginTop:"1px"}}>✓</span>
    <div><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"}}>Your invoice has been sent to [billing@company.com](mailto:billing@company.com)</div></div>
  </div>
</div>

```tsx theme={null}
<Alert
  variant="success"
  title="Payment successful"
  description="Your invoice has been sent to billing@company.com"
/>
```

### Warning

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{background:"#fffaeb",border:"1px solid #fec84b",borderRadius:"8px",padding:"14px 16px",display:"flex",gap:"12px",alignItems:"flex-start"}}>
    <span style={{color:"#b54708",fontSize:"16px",marginTop:"1px"}}>⚠</span>
    <div><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"}}>You have used 90% of your 5 GB storage limit.</div></div>
  </div>
</div>

```tsx theme={null}
<Alert
  variant="warning"
  title="Storage almost full"
  description="You have used 90% of your 5 GB storage limit."
/>
```

### Error

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{background:"#fef3f2",border:"1px solid #fecdca",borderRadius:"8px",padding:"14px 16px",display:"flex",gap:"12px",alignItems:"flex-start"}}>
    <span style={{color:"#b42318",fontSize:"16px",marginTop:"1px"}}>✕</span>
    <div><div style={{fontSize:"14px",fontWeight:600,color:"#b42318",fontFamily:"Inter,sans-serif"}}>Failed to save</div><div style={{fontSize:"13px",color:"#b42318",fontFamily:"Inter,sans-serif",marginTop:"2px"}}>There was an error saving your changes. Please try again.</div></div>
  </div>
</div>

```tsx theme={null}
<Alert
  variant="error"
  title="Failed to save"
  description="There was an error saving your changes. Please try again."
/>
```

### Destructive

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{background:"#fef2f2",border:"2px solid #DC2626",borderLeft:"4px solid #DC2626",borderRadius:"8px",padding:"14px 16px",display:"flex",gap:"12px",alignItems:"flex-start"}}>
    <span style={{color:"#DC2626",fontSize:"16px",marginTop:"1px"}}>⛔</span>
    <div><div style={{fontSize:"14px",fontWeight:600,color:"#b42318",fontFamily:"Inter,sans-serif"}}>Account will be deleted</div><div style={{fontSize:"13px",color:"#b42318",fontFamily:"Inter,sans-serif",marginTop:"2px"}}>This action cannot be undone. All data will be permanently removed.</div></div>
  </div>
</div>

```tsx theme={null}
<Alert
  variant="destructive"
  title="Account will be deleted"
  description="This action cannot be undone. All data will be permanently removed."
/>
```

<Warning>
  Always pair a `destructive` Alert with a confirmation dialog before the user can trigger the action.
</Warning>

### With Action

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{background:"#fffaeb",border:"1px solid #fec84b",borderRadius:"8px",padding:"14px 16px",display:"flex",gap:"12px",alignItems:"flex-start",justifyContent:"space-between"}}>
    <div style={{display:"flex",gap:"12px",alignItems:"flex-start"}}>
      <span style={{color:"#b54708",fontSize:"16px",marginTop:"1px"}}>⚠</span>
      <div><div style={{fontSize:"14px",fontWeight:600,color:"#b54708",fontFamily:"Inter,sans-serif"}}>Your session is expiring</div><div style={{fontSize:"13px",color:"#b54708",fontFamily:"Inter,sans-serif",marginTop:"2px"}}>You will be logged out in 5 minutes.</div></div>
    </div>

    <button style={{background:"#fff",border:"1px solid #fec84b",borderRadius:"6px",padding:"6px 12px",fontSize:"12px",fontWeight:500,color:"#b54708",cursor:"pointer",whiteSpace:"nowrap",flexShrink:0}}>Stay logged in</button>
  </div>
</div>

```tsx theme={null}
<Alert
  variant="warning"
  title="Your session is expiring"
  description="You will be logged out in 5 minutes."
  action={
    <Button size="sm" variant="outline">Stay logged in</Button>
  }
/>
```

***

## API Reference

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

<ParamField path="title" type="string">
  Bold heading text of the alert.
</ParamField>

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

<ParamField path="icon" type="ReactNode">
  Custom leading icon. When omitted, a default icon is used per variant.
</ParamField>

<ParamField path="action" type="ReactNode">
  Optional action element (e.g. a Button) placed at the end of the alert.
</ParamField>

<ParamField path="className" type="string">
  Additional Tailwind classes for custom overrides.
</ParamField>

***

## Accessibility

* Alert uses `role="alert"` so screen readers announce it when it appears in the DOM
* Do not place multiple Alerts on the same page simultaneously — use one at a time
* Icon alone does not convey the meaning — always pair with `title` or `description`
* Action links inside alerts should have descriptive text, not just "Click here"

***

## Do's & Don'ts

<CardGroup cols={2}>
  <Card title="Do" icon="check" iconType="solid" color="#16A34A">
    * Use the correct semantic variant for the type of feedback
    * Place Alerts at the top of the relevant form or section
    * Use `action` prop for clear next steps (e.g. "Retry", "Contact support")
    * Keep descriptions concise — one sentence is ideal
  </Card>

  <Card title="Don't" icon="xmark" iconType="solid" color="#DC2626">
    * Don't stack multiple Alerts at once — prioritize the most important one
    * Don't use Alert for transient feedback — use Toast instead
    * Don't use the `destructive` variant for regular errors
    * Don't use Alerts as decorative banners with no actionable meaning
  </Card>
</CardGroup>
