> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# Alert

Draw attention to a message inside the page, such as a tip, a warning or an error, in a bordered box.


## Installation

```bash
npx @blotch/dolan add alert
```

```typescript
import { UiAlert } from '../components/ui/alert';
```

Alert imports `class-variance-authority` (see [Installation](/dolan/index.md#installation)).

## Usage

```typescript
import { Component } from '@angular/core';
import { UiAlert } from '../components/ui/alert';

@Component({
  selector: 'app-tip',
  imports: [UiAlert],
  template: `
    <ui-alert
      title="Heads up!"
      description="You can add components to your app using the CLI."
    />
  `,
})
export class Tip {}
```

- The alert sits in the page flow. It doesn't float over content or block taps. For that, use [Toast](/dolan/toast.md) or [Alert Dialog](/dolan/alert-dialog.md).
- It slides up and fades in when it first renders.

### Destructive

```angular-html
<ui-alert
  variant="destructive"
  title="Error"
  description="Your session has expired. Please log in again."
/>
```

The destructive variant tints the background and colors the border and text red.

### Custom content

Put elements inside to add them below the title and description. Wrap text in `<text>`, and import `LYNX_ELEMENTS` in your component.

```angular-html
<ui-alert title="Update available">
  <text class="mt-2 text-sm text-muted-foreground">
    A new version of the app is ready. Restart to apply it.
  </text>
</ui-alert>
```

## API

### UiAlert

| Input         | Type                         | Default     | Description                              |
| ------------- | ---------------------------- | ----------- | ---------------------------------------- |
| `variant`     | `'default' \| 'destructive'` | `'default'` | Visual style.                            |
| `title`       | `string`                     | `''`        | Title text. Hidden when empty.           |
| `description` | `string`                     | `''`        | Text below the title. Hidden when empty. |
| `class`       | `string`                     | `''`        | Extra Tailwind classes for the box.      |

No outputs.

The file also exports `alertVariants`, the `class-variance-authority` function that returns the box's classes for a variant, and the `AlertVariant` type.

## Related

- [Toast](/dolan/toast.md): a brief message that floats over the app
- [Alert Dialog](/dolan/alert-dialog.md): ask the user to confirm
- [Theming](/dolan/theming.md): change the colors the variants use
