> For AI agents: the complete documentation index is available at https://rickyshin93.github.io/tao-ui/llms.txt, the full documentation bundle is available at https://rickyshin93.github.io/tao-ui/llms-full.txt.

# Alert

Feedback`@rockshin/tao-ui`

[Examples](#examples)[API](#api)

Displays important contextual feedback messages with semantic status types.

## When to use

Use Alert for persistent, page-level feedback about a state or operation. Use Sonner toasts for transient notifications.

**Recommended**

- Pick the semantic type that matches the severity of the message.
- Keep the title short; put detail in the description.
- Enable showIcon when the alert needs to be scannable at a glance.

**Avoid**

- Do not stack many alerts in one view; prefer a single summary.
- Do not use Alert for transient feedback; use a toast instead.

## Examples


### Basic usage
```tsx preview
import { Alert, Stack } from '@rockshin/tao-ui';

function AlertExample() {
  return (
    <Stack gap="md">
      <Alert type="success" title="Changes saved" showIcon />
      <Alert
        type="info"
        title="New version available"
        description="Refresh when you are ready."
        showIcon
      />
      <Alert type="warning" title="Subscription expires soon" showIcon />
      <Alert type="error" title="Could not save changes" showIcon />
    </Stack>
  );
}

export default AlertExample;
```

### Descriptions and icons
```tsx preview
import { Alert, Stack } from '@rockshin/tao-ui';

function DetailedAlerts() {
  return (
    <Stack gap="md">
      <Alert
        type="success"
        title="Deployment complete"
        description="Production is running version 0.0.25."
        showIcon
      />
      <Alert
        type="info"
        title="Update available"
        description="Refresh when you are ready."
        showIcon
      />
      <Alert
        type="warning"
        title="Quota almost reached"
        description="Storage is 92% full."
        showIcon
      />
      <Alert
        type="error"
        title="Build failed"
        description="Fix the type errors and run again."
        showIcon
      />
    </Stack>
  );
}

export default DetailedAlerts;
```

### Closable alerts and actions
```tsx preview
import { Alert, Button, Stack } from '@rockshin/tao-ui';

function ActionAlerts() {
  return (
    <Stack gap="md">
      <Alert type="info" title="Closable message" closable showIcon />
      <Alert
        type="warning"
        title="Payment method expires soon"
        description="Update it before the next billing date."
        showIcon
        action={
          <Button size="small" variant="secondary">
            Update
          </Button>
        }
      />
      <Alert
        type="error"
        title="Connection lost"
        action={<Button size="small">Retry</Button>}
        closable
        showIcon
      />
    </Stack>
  );
}

export default ActionAlerts;
```

### Title and description
Use `description` for the cause and recovery while keeping the title concise.
```tsx preview
import { Alert, Stack } from '@rockshin/tao-ui';

export default function AlertWithDescription() {
  return (
    <Stack gap="md">
      <Alert
        type="success"
        title="Success"
        description="Your changes have been saved successfully."
      />
      <Alert
        type="info"
        title="Info"
        description="A new version is available. Refresh to update."
      />
      <Alert
        type="warning"
        title="Warning"
        description="Your subscription expires in 3 days."
      />
      <Alert
        type="error"
        title="Error"
        description="Something went wrong while processing your request."
      />
    </Stack>
  );
}
```

### Status icons
`showIcon` adds the matching success, information, warning, or error icon.
```tsx preview
import { Alert, Stack } from '@rockshin/tao-ui';

export default function AlertWithIcon() {
  return (
    <Stack gap="md">
      <Alert type="success" title="Success" showIcon />
      <Alert type="info" title="Info" showIcon />
      <Alert type="warning" title="Warning" showIcon />
      <Alert type="error" title="Error" showIcon />
      <Alert
        type="success"
        title="Success"
        description="Icons grow larger when a description is present."
        showIcon
      />
      <Alert
        type="warning"
        title="Custom Icon"
        showIcon
        icon={<span>🔥</span>}
      />
    </Stack>
  );
}
```

### Inline actions
Use `action` for an operation related to the message and provide feedback when it completes.
```tsx preview
import { useState } from 'react';
import { Alert, Button, Stack } from '@rockshin/tao-ui';
export default function Example() {
  const [updated, setUpdated] = useState(false);
  const [retried, setRetried] = useState(false);
  return (
    <Stack>
      <Alert
        type={updated ? 'success' : 'info'}
        title={updated ? 'Demo update applied' : 'New version available'}
        showIcon
        action={
          <Button
            size="small"
            disabled={updated}
            onClick={() => setUpdated(true)}
          >
            Update
          </Button>
        }
      />
      <Alert
        type={retried ? 'success' : 'error'}
        title={retried ? 'Demo retry completed' : 'Request failed'}
        description="These actions update local example state."
        showIcon
        action={
          <Button
            size="small"
            disabled={retried}
            onClick={() => setRetried(true)}
          >
            Retry
          </Button>
        }
      />
    </Stack>
  );
}
```

## API


### [#](#alert)Alert



| Property | Description | Type | Default Value |
| --- | --- | --- | --- |
| className | Additional css class | `string | undefined` | `-` |
| style | Additional style | `CSSProperties | undefined` | `-` |

