> For AI agents: the complete documentation index is available at https://wallarm.github.io/design-system/llms.txt, the full documentation bundle is available at https://wallarm.github.io/design-system/llms-full.txt.

# Alert

An inline message bound to one part of the screen, which stays until the state changes or the reader dismisses it — reach for `Banner` when the message would still matter on another page, `Toast` for a transient confirmation, and the field’s own error for a single invalid input. `color` carries the meaning and `AlertIcon` takes its icon from it, so the pair is not yours to mix; `primary` is the neutral default for a notice with no status to encode.

[Source](https://github.com/wallarm/design-system/tree/main/packages/design-system/src/components/Alert) · [Storybook](https://wallarm.github.io/design-system/storybook/?path=/docs/messaging-alert--overview)

```tsx
import { Alert, AlertContent, AlertDescription, AlertIcon, AlertTitle } from '@wallarm-org/design-system/Alert';

export const AllColors = () => (
  <div className='flex flex-col gap-16 w-[600px]'>
    <Alert color='primary'>
      <AlertIcon />
      <AlertContent>
        <AlertTitle>Primary Alert</AlertTitle>
        <AlertDescription>This is a neutral alert for general information.</AlertDescription>
      </AlertContent>
    </Alert>

    <Alert color='destructive'>
      <AlertIcon />
      <AlertContent>
        <AlertTitle>Destructive Alert</AlertTitle>
        <AlertDescription>This alert indicates an error or dangerous action.</AlertDescription>
      </AlertContent>
    </Alert>

    <Alert color='info'>
      <AlertIcon />
      <AlertContent>
        <AlertTitle>Info Alert</AlertTitle>
        <AlertDescription>This alert provides informational content to the user.</AlertDescription>
      </AlertContent>
    </Alert>

    <Alert color='warning'>
      <AlertIcon />
      <AlertContent>
        <AlertTitle>Warning Alert</AlertTitle>
        <AlertDescription>This alert warns the user about potential issues.</AlertDescription>
      </AlertContent>
    </Alert>

    <Alert color='success'>
      <AlertIcon />
      <AlertContent>
        <AlertTitle>Success Alert</AlertTitle>
        <AlertDescription>This alert confirms a successful action or operation.</AlertDescription>
      </AlertContent>
    </Alert>
  </div>
);
```

## Usage

```tsx
import { Alert, AlertContent, AlertDescription, AlertIcon, AlertTitle } from '@wallarm-org/design-system/Alert';
```

## Examples

### Title only

A title on its own is a complete alert. Add a description only when it says something the title does not.

```tsx
import { Alert, AlertContent, AlertIcon, AlertTitle } from '@wallarm-org/design-system/Alert';

export const TitleOnly = () => {
  return (
    <div className='flex flex-col gap-16 w-[600px]'>
      <Alert color='primary'>
        <AlertIcon />
        <AlertContent>
          <AlertTitle>Alert with title only</AlertTitle>
        </AlertContent>
      </Alert>

      <Alert color='info'>
        <AlertIcon />
        <AlertContent>
          <AlertTitle>Information message without description</AlertTitle>
        </AlertContent>
      </Alert>
    </div>
  );
};
```

### With close button

`AlertClose` gives the reader a way out — add it where dismissing is reasonable, and leave it off while the condition still holds.

```tsx
import { useState } from 'react';
import { Alert, AlertClose, AlertContent, AlertDescription, AlertIcon, AlertTitle } from '@wallarm-org/design-system/Alert';

export const WithCloseButton = () => {
  const [showInfo, setShowInfo] = useState(true);
  const [showWarning, setShowWarning] = useState(true);

  return (
    <div className='flex flex-col gap-16 w-[600px]'>
      {showInfo && (
        <Alert color='info'>
          <AlertIcon />
          <AlertContent>
            <AlertTitle>Dismissable Alert</AlertTitle>
            <AlertDescription>This alert can be closed by clicking the X button.</AlertDescription>
          </AlertContent>
          <AlertClose onClick={() => setShowInfo(false)} />
        </Alert>
      )}

      {showWarning && (
        <Alert color='warning'>
          <AlertIcon />
          <AlertContent>
            <AlertTitle>Warning with close</AlertTitle>
          </AlertContent>
          <AlertClose onClick={() => setShowWarning(false)} />
        </Alert>
      )}
    </div>
  );
};
```

### With controls

`AlertControls` as a direct child of `Alert` puts the actions top-right, which is what a wide alert wants. The buttons are always `secondary` and `small`, neutral or destructive to match the alert, never a solid primary.

```tsx
import { Alert, AlertClose, AlertContent, AlertControls, AlertDescription, AlertIcon, AlertTitle } from '@wallarm-org/design-system/Alert';
import { Button } from '@wallarm-org/design-system/Button';

export const WithControls = () => {
  return (
    <div className='flex flex-col gap-16 w-[600px]'>
      <Alert color='info'>
        <AlertIcon />
        <AlertContent>
          <AlertTitle>Alert with Two Action Buttons</AlertTitle>
          <AlertDescription>
            This alert has two action buttons on the right side without a close button.
          </AlertDescription>
        </AlertContent>
        <AlertControls>
          <Button variant='secondary' color='neutral' size='small'>
            Learn more
          </Button>
          <Button variant='secondary' color='neutral' size='small'>
            Dismiss
          </Button>
        </AlertControls>
      </Alert>

      <Alert color='info'>
        <AlertIcon />
        <AlertContent>
          <AlertTitle>Alert with Actions and Close</AlertTitle>
          <AlertDescription>This alert has action buttons and a close button.</AlertDescription>
        </AlertContent>
        <AlertControls>
          <Button variant='secondary' color='neutral' size='small'>
            Learn more
          </Button>
        </AlertControls>
        <AlertClose />
      </Alert>

      <Alert color='destructive'>
        <AlertIcon />
        <AlertContent>
          <AlertTitle>Critical Error</AlertTitle>
          <AlertDescription>An error occurred that requires your attention.</AlertDescription>
        </AlertContent>
        <AlertControls>
          <Button variant='secondary' color='destructive' size='small'>
            Fix now
          </Button>
        </AlertControls>
        <AlertClose />
      </Alert>
    </div>
  );
};
```

### With bottom actions

The same controls nested inside `AlertContent` drop below the text instead, which is what a narrow alert wants. Placement follows the width rather than a rule.

```tsx
import { Alert, AlertClose, AlertContent, AlertControls, AlertDescription, AlertIcon, AlertTitle } from '@wallarm-org/design-system/Alert';
import { Button } from '@wallarm-org/design-system/Button';

export const WithBottomActions = () => {
  return (
    <div className='flex flex-col gap-16 w-[600px]'>
      <Alert color='info'>
        <AlertIcon />
        <AlertContent>
          <AlertTitle>Alert with Bottom Actions</AlertTitle>
          <AlertDescription>
            This alert has action buttons at the bottom of the content area.
          </AlertDescription>
          <AlertControls>
            <Button variant='secondary' color='neutral' size='small'>
              Primary Action
            </Button>
            <Button variant='secondary' color='neutral' size='small'>
              Secondary
            </Button>
          </AlertControls>
        </AlertContent>
        <AlertClose />
      </Alert>

      <Alert color='destructive'>
        <AlertIcon />
        <AlertContent>
          <AlertTitle>Destructive Alert with Actions</AlertTitle>
          <AlertDescription>
            This error requires immediate action. Please review and take necessary steps.
          </AlertDescription>
          <AlertControls>
            <Button variant='secondary' color='destructive' size='small'>
              Delete
            </Button>
            <Button variant='secondary' color='neutral' size='small'>
              Cancel
            </Button>
          </AlertControls>
        </AlertContent>
      </Alert>
    </div>
  );
};
```

### Min max width

Each row puts the alert in a container that crosses one of its bounds, since
neither is visible in a container that sits between them. The alert has no width
of its own: it takes the container's, clamped between 256 and 980px.

```tsx
import { Alert, AlertClose, AlertContent, AlertDescription, AlertIcon, AlertTitle } from '@wallarm-org/design-system/Alert';

export const MinMaxWidth = () => {
  const edge = 'border border-dashed border-border-primary';
  return (
    <div className='flex flex-col gap-24'>
      <div>
        <div className={`w-[200px] ${edge}`}>
          <Alert color='info'>
            <AlertIcon />
            <AlertContent>
              <AlertTitle>Short</AlertTitle>
            </AlertContent>
          </Alert>
        </div>
      </div>
      <div>
        <div className={`w-[600px] ${edge}`}>
          <Alert color='warning'>
            <AlertIcon />
            <AlertContent>
              <AlertTitle>
                This is a very long alert title that demonstrates the maximum width behavior of the
                component
              </AlertTitle>
              <AlertDescription>
                This is an extended description that shows how the alert handles longer content, and
                wraps within whatever width the container gives it.
              </AlertDescription>
            </AlertContent>
            <AlertClose />
          </Alert>
        </div>
      </div>
      <div className='overflow-x-auto'>
        <div className={`w-[1100px] ${edge}`}>
          <Alert color='primary'>
            <AlertIcon />
            <AlertContent>
              <AlertTitle>
                Past 980px the alert stops widening and leaves the rest of the container empty
              </AlertTitle>
              <AlertDescription>
                A line of text long enough to reach the ceiling, so the gap on the right is the
                ceiling rather than the content running out.
              </AlertDescription>
            </AlertContent>
            <AlertClose />
          </Alert>
        </div>
      </div>
      <div>
        <div className={`w-[600px] ${edge}`}>
          <Alert color='success' maxWidth={500}>
            <AlertIcon />
            <AlertContent>
              <AlertTitle>
                This is a very long alert title that demonstrates the custom maximum width behavior
              </AlertTitle>
              <AlertDescription>
                This alert has a custom maxWidth of 500px set via prop.
              </AlertDescription>
            </AlertContent>
            <AlertClose />
          </Alert>
        </div>
      </div>
    </div>
  );
};
```

### Max lines

`lineClamp` is opt-in: without it long text wraps freely, and with it the text truncates and the full string moves into a tooltip. Four lines is the usual cap.

```tsx
import { Alert, AlertContent, AlertDescription, AlertIcon, AlertTitle } from '@wallarm-org/design-system/Alert';

export const MaxLines = () => {
  const longTitle =
    'This is a very long title that should be truncated after a certain number of lines. It keeps going and going to demonstrate the line clamp functionality. We need even more text to ensure it exceeds the maximum number of lines allowed.';
  const longDescription =
    'This is a very long description that demonstrates the text truncation feature. The description can be quite lengthy and should be limited to a maximum of 4 lines by default. When the text exceeds this limit, it will be truncated with an ellipsis. This behavior ensures that the alert remains compact and does not take up too much vertical space on the page. Additional text is added here to make sure the truncation is visible.';
  return (
    <div className='flex flex-col gap-16 w-600'>
      <div>
        <Alert color='info'>
          <AlertIcon />
          <AlertContent>
            <AlertTitle lineClamp={4}>{longTitle}</AlertTitle>
            <AlertDescription lineClamp={4}>{longDescription}</AlertDescription>
          </AlertContent>
        </Alert>
      </div>
      <div>
        <Alert color='warning'>
          <AlertIcon />
          <AlertContent>
            <AlertTitle lineClamp={2}>{longTitle}</AlertTitle>
            <AlertDescription lineClamp={2}>{longDescription}</AlertDescription>
          </AlertContent>
        </Alert>
      </div>
      <div>
        <Alert color='success'>
          <AlertIcon />
          <AlertContent>
            <AlertTitle>{longTitle}</AlertTitle>
            <AlertDescription>{longDescription}</AlertDescription>
          </AlertContent>
        </Alert>
      </div>
    </div>
  );
};
```

### With code

An inline `Code` line inside the content, for the error code or the command that failed — the one piece of rich content an alert is built to carry.

```tsx
import { Alert, AlertClose, AlertContent, AlertDescription, AlertIcon, AlertTitle } from '@wallarm-org/design-system/Alert';
import { Code } from '@wallarm-org/design-system/Code';

export const WithCode = () => (
  <div className='flex flex-col gap-16 w-700'>
    <Alert color='destructive'>
      <AlertIcon />
      <AlertContent>
        <AlertTitle>Message goes here</AlertTitle>
        <AlertDescription>Description goes here</AlertDescription>
        <div className='pt-8'>
          <Code size='s' color='destructive'>
            Optional code output
          </Code>
        </div>
      </AlertContent>
    </Alert>

    <Alert color='destructive'>
      <AlertIcon />
      <AlertContent>
        <AlertTitle>Syntax Error in Configuration</AlertTitle>
        <AlertDescription>An error occurred while parsing the configuration file.</AlertDescription>

        <div className='pt-8'>
          <Code size='s' color='destructive'>
            Error: Unexpected token at line 42, column 15
          </Code>
        </div>
      </AlertContent>
      <AlertClose />
    </Alert>
  </div>
);
```

## Props

| Prop           | Type                                                 | Default           | Description                            |
| -------------- | ---------------------------------------------------- | ----------------- | -------------------------------------- |
| color          | `AlertColor \| undefined`                            | `primary`         | Color variant of the alert             |
| minWidth       | `number \| undefined`                                | `ALERT_MIN_WIDTH` | Minimum width in pixels (default: 256) |
| maxWidth       | `number \| undefined`                                | `ALERT_MAX_WIDTH` | Maximum width in pixels (default: 980) |
| title          | `string \| undefined`                                |                   |                                        |
| defaultChecked | `boolean \| undefined`                               |                   |                                        |
| defaultValue   | `string \| number \| readonly string[] \| undefined` |                   |                                        |
| autoFocus      | `boolean \| undefined`                               |                   |                                        |
| id             | `string \| undefined`                                |                   |                                        |
| tabIndex       | `number \| undefined`                                |                   |                                        |
| rel            | `string \| undefined`                                |                   |                                        |
| onChange       | `ChangeEventHandler<T, Element> \| undefined`        |                   |                                        |
| data-testid    | `string \| undefined`                                |                   |                                        |

### AlertClose

| Prop           | Type                                                 | Default | Description                               |
| -------------- | ---------------------------------------------------- | ------- | ----------------------------------------- |
| onClick        | `(() => void) \| undefined`                          |         | Callback when the close button is clicked |
| title          | `string \| undefined`                                |         |                                           |
| defaultChecked | `boolean \| undefined`                               |         |                                           |
| defaultValue   | `string \| number \| readonly string[] \| undefined` |         |                                           |
| autoFocus      | `boolean \| undefined`                               |         |                                           |
| id             | `string \| undefined`                                |         |                                           |
| tabIndex       | `number \| undefined`                                |         |                                           |
| rel            | `string \| undefined`                                |         |                                           |
| onChange       | `ChangeEventHandler<T, Element> \| undefined`        |         |                                           |
| type           | `"button" \| "submit" \| "reset" \| undefined`       |         |                                           |
| disabled       | `boolean \| undefined`                               |         |                                           |
| name           | `string \| undefined`                                |         |                                           |
| value          | `string \| number \| readonly string[] \| undefined` |         |                                           |

### AlertContent

| Prop           | Type                                                 | Default | Description |
| -------------- | ---------------------------------------------------- | ------- | ----------- |
| defaultChecked | `boolean \| undefined`                               |         |             |
| defaultValue   | `string \| number \| readonly string[] \| undefined` |         |             |
| autoFocus      | `boolean \| undefined`                               |         |             |
| id             | `string \| undefined`                                |         |             |
| tabIndex       | `number \| undefined`                                |         |             |
| title          | `string \| undefined`                                |         |             |
| rel            | `string \| undefined`                                |         |             |
| onChange       | `ChangeEventHandler<T, Element> \| undefined`        |         |             |

### AlertControls

| Prop           | Type                                                 | Default | Description |
| -------------- | ---------------------------------------------------- | ------- | ----------- |
| title          | `string \| undefined`                                |         |             |
| defaultChecked | `boolean \| undefined`                               |         |             |
| defaultValue   | `string \| number \| readonly string[] \| undefined` |         |             |
| autoFocus      | `boolean \| undefined`                               |         |             |
| id             | `string \| undefined`                                |         |             |
| tabIndex       | `number \| undefined`                                |         |             |
| rel            | `string \| undefined`                                |         |             |
| onChange       | `ChangeEventHandler<T, Element> \| undefined`        |         |             |

### AlertDescription

| Prop           | Type                                                 | Default | Description                                                                             |
| -------------- | ---------------------------------------------------- | ------- | --------------------------------------------------------------------------------------- |
| lineClamp      | `number \| undefined`                                |         | Maximum number of lines before truncation (default: 4). Set to 0 to disable truncation. |
| title          | `string \| undefined`                                |         |                                                                                         |
| defaultChecked | `boolean \| undefined`                               |         |                                                                                         |
| defaultValue   | `string \| number \| readonly string[] \| undefined` |         |                                                                                         |
| autoFocus      | `boolean \| undefined`                               |         |                                                                                         |
| id             | `string \| undefined`                                |         |                                                                                         |
| tabIndex       | `number \| undefined`                                |         |                                                                                         |
| rel            | `string \| undefined`                                |         |                                                                                         |
| onChange       | `ChangeEventHandler<T, Element> \| undefined`        |         |                                                                                         |

### AlertIcon

| Prop           | Type                                                 | Default | Description                               |
| -------------- | ---------------------------------------------------- | ------- | ----------------------------------------- |
| icon           | `ReactNode`                                          |         | Override the default icon for the variant |
| title          | `string \| undefined`                                |         |                                           |
| defaultChecked | `boolean \| undefined`                               |         |                                           |
| defaultValue   | `string \| number \| readonly string[] \| undefined` |         |                                           |
| autoFocus      | `boolean \| undefined`                               |         |                                           |
| id             | `string \| undefined`                                |         |                                           |
| tabIndex       | `number \| undefined`                                |         |                                           |
| rel            | `string \| undefined`                                |         |                                           |
| onChange       | `ChangeEventHandler<T, Element> \| undefined`        |         |                                           |

### AlertTitle

| Prop           | Type                                                 | Default | Description                                                                             |
| -------------- | ---------------------------------------------------- | ------- | --------------------------------------------------------------------------------------- |
| lineClamp      | `number \| undefined`                                |         | Maximum number of lines before truncation (default: 4). Set to 0 to disable truncation. |
| title          | `string \| undefined`                                |         |                                                                                         |
| defaultChecked | `boolean \| undefined`                               |         |                                                                                         |
| defaultValue   | `string \| number \| readonly string[] \| undefined` |         |                                                                                         |
| autoFocus      | `boolean \| undefined`                               |         |                                                                                         |
| id             | `string \| undefined`                                |         |                                                                                         |
| tabIndex       | `number \| undefined`                                |         |                                                                                         |
| rel            | `string \| undefined`                                |         |                                                                                         |
| onChange       | `ChangeEventHandler<T, Element> \| undefined`        |         |                                                                                         |

## Explorer

