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

# Banner

A full-width message pinned above the header, for something account- or system-wide. The test is whether it would still matter on another page: yes and it is a `Banner`, no and it is an `Alert`. There is no success variant — “it worked” is a `Toast` — and no `icon` prop either: the icon appears only when a `BannerIcon` is composed in.

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

```tsx
import { Banner, BannerClose, BannerContent, BannerControls, BannerDescription, BannerIcon, BannerLink, BannerTitle } from '@wallarm-org/design-system/Banner';
import { Button } from '@wallarm-org/design-system/Button';
import { Megaphone } from '@wallarm-org/design-system/icons';

export const Default = ({
  variant,
  customIcon,
  description,
  inlineAction,
  actions,
  closable,
  title,
  text,
}) => (
  <Banner variant={variant}>
    <BannerIcon
      icon={customIcon ? <Megaphone size='lg' className='text-icon-brand' /> : undefined}
    />
    <BannerContent>
      <BannerTitle action={inlineAction ? <BannerLink href='#'>Action</BannerLink> : undefined}>
        {title}
      </BannerTitle>
      {description && <BannerDescription>{text}</BannerDescription>}
    </BannerContent>
    {(actions || closable) && (
      <BannerControls>
        {actions && (
          <Button variant='secondary' color='neutral' size='small'>
            Button
          </Button>
        )}
        {closable && <BannerClose />}
      </BannerControls>
    )}
  </Banner>
);
```

## Usage

```tsx
import { Banner, BannerClose, BannerContent, BannerControls, BannerDescription, BannerIcon, BannerLink, BannerTitle } from '@wallarm-org/design-system/Banner';
import { Button } from '@wallarm-org/design-system/Button';
import { Megaphone } from '@wallarm-org/design-system/icons';
```

## Examples

### All colors

`primary` (dark) and `secondary` (light) are the neutral bars and carry no icon of their own; destructive, info and warning each bring one.

```tsx
import { Banner, BannerContent, BannerIcon, BannerTitle } from '@wallarm-org/design-system/Banner';

export const AllColors = () => (
  <div className='flex flex-col gap-16'>
    <Banner variant='primary'>
      <BannerContent>
        <BannerTitle>Message goes here</BannerTitle>
      </BannerContent>
    </Banner>

    <Banner variant='secondary'>
      <BannerContent>
        <BannerTitle>Message goes here</BannerTitle>
      </BannerContent>
    </Banner>

    <Banner variant='destructive'>
      <BannerIcon />
      <BannerContent>
        <BannerTitle>Message goes here</BannerTitle>
      </BannerContent>
    </Banner>

    <Banner variant='info'>
      <BannerIcon />
      <BannerContent>
        <BannerTitle>Message goes here</BannerTitle>
      </BannerContent>
    </Banner>

    <Banner variant='warning'>
      <BannerIcon />
      <BannerContent>
        <BannerTitle>Message goes here</BannerTitle>
      </BannerContent>
    </Banner>
  </div>
);
```

### With description

A description earns its place by adding the consequence — here the node version the feature needs — never by restating the title.

```tsx
import { Banner, BannerContent, BannerDescription, BannerIcon, BannerTitle } from '@wallarm-org/design-system/Banner';

export const WithDescription = () => (
  <Banner variant='info'>
    <BannerIcon />
    <BannerContent>
      <BannerTitle>Credential Stuffing Detection</BannerTitle>
      <BannerDescription>
        Credential Stuffing Detection requires Wallarm node version 4.10.3 or higher.
      </BannerDescription>
    </BannerContent>
  </Banner>
);
```

### With inline link

A `BannerLink` inside the title, for when the action belongs in the sentence. Use the inline link or the trailing buttons, never both.

```tsx
import { Banner, BannerContent, BannerIcon, BannerLink, BannerTitle } from '@wallarm-org/design-system/Banner';

export const WithInlineLink = () => (
  <Banner variant='warning'>
    <BannerIcon />
    <BannerContent>
      <BannerTitle action={<BannerLink href='#'>Learn more</BannerLink>}>
        You have exceeded the monthly quota for your company
      </BannerTitle>
    </BannerContent>
  </Banner>
);
```

### Long text

Two lines is the ceiling, after which the text truncates into a tooltip. One line is what to aim for.

```tsx
import { Banner, BannerClose, BannerContent, BannerControls, BannerTitle } from '@wallarm-org/design-system/Banner';

export const LongText = () => (
  <Banner variant='primary'>
    <BannerContent>
      <BannerTitle lineClamp={2}>
        Banner will render at most two lines before truncating the text. Banners address system-wide
        conditions, not individual user actions. The voice should be institutional and factual, even
        when the situation is urgent. Every word must earn its place within the 2-line budget, but
        one line is more preferred.
      </BannerTitle>
    </BannerContent>
    <BannerControls>
      <BannerClose />
    </BannerControls>
  </Banner>
);
```

### Custom icon

`BannerIcon`’s `icon` prop overrides the variant default, or gives `primary` and `secondary` the icon they otherwise lack — which is how an announcement gets its megaphone.

```tsx
import { Banner, BannerClose, BannerContent, BannerControls, BannerIcon, BannerLink, BannerTitle } from '@wallarm-org/design-system/Banner';
import { Megaphone } from '@wallarm-org/design-system/icons';

export const CustomIcon = () => (
  <Banner variant='secondary'>
    <BannerIcon icon={<Megaphone size='lg' className='text-icon-brand' />} />
    <BannerContent>
      <BannerTitle action={<BannerLink href='#'>View plans</BannerLink>}>
        New features are now available on the Pro plan
      </BannerTitle>
    </BannerContent>
    <BannerControls>
      <BannerClose />
    </BannerControls>
  </Banner>
);
```

### With actions

Trailing buttons in `BannerControls`, small and never solid, labelled with the verb that follows: “Renew”, not “Learn more”.

```tsx
import { Banner, BannerContent, BannerControls, BannerIcon, BannerTitle } from '@wallarm-org/design-system/Banner';
import { Button } from '@wallarm-org/design-system/Button';

export const WithActions = () => (
  <Banner variant='destructive'>
    <BannerIcon />
    <BannerContent>
      <BannerTitle>Your subscription has expired</BannerTitle>
    </BannerContent>
    <BannerControls>
      <Button variant='outline' color='neutral' size='small'>
        Dismiss
      </Button>
      <Button variant='outline' color='neutral' size='small'>
        Renew
      </Button>
    </BannerControls>
  </Banner>
);
```

### Closable

`BannerClose` where the reader may dismiss it. Leave it off while the condition still holds, since a banner is meant to outlast a page view.

```tsx
import { useState } from 'react';
import { Banner, BannerClose, BannerContent, BannerControls, BannerTitle } from '@wallarm-org/design-system/Banner';
import { Button } from '@wallarm-org/design-system/Button';

export const Closable = () => {
  const [open, setOpen] = useState(true);

  if (!open) {
    return (
      <div className='p-16'>
        <Button onClick={() => setOpen(true)}>Show banner</Button>
      </div>
    );
  }

  return (
    <Banner variant='primary'>
      <BannerContent>
        <BannerTitle>A new version of the dashboard is available</BannerTitle>
      </BannerContent>
      <BannerControls>
        <BannerClose onClick={() => setOpen(false)} />
      </BannerControls>
    </Banner>
  );
};
```

## Props

| Prop           | Type                                                 | Default   | Description                  |
| -------------- | ---------------------------------------------------- | --------- | ---------------------------- |
| variant        | `BannerVariant \| undefined`                         | `primary` | Visual variant of the banner |
| 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`        |           |                              |
| data-testid    | `string \| undefined`                                |           |                              |

### BannerClose

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

### BannerContent

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

### BannerControls

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

### BannerDescription

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

### BannerIcon

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

### BannerLink

| 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`        |           |             |
| disabled       | `{ true: string; }`                                  |           |             |
| asChild        | `boolean \| undefined`                               |           |             |
| weight         | `{ regular: string; medium: string; }`               | `regular` |             |
| href           | `string \| undefined`                                |           |             |
| download       | `any`                                                |           |             |
| hrefLang       | `string \| undefined`                                |           |             |
| target         | `HTMLAttributeAnchorTarget \| undefined`             |           |             |
| data-testid    | `string \| undefined`                                |           |             |

### BannerTitle

| Prop           | Type                                                 | Default | Description                                                                                                                      |
| -------------- | ---------------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- |
| action         | `ReactNode`                                          |         | Optional inline action rendered next to the title (e.g. a BannerLink). Sits on the same row and wraps below on narrow viewports. |
| lineClamp      | `number \| undefined`                                | `1`     | Maximum number of lines before the message is truncated (default: 1). The design budget is 2 lines; 1 line is preferred.         |
| 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

