Alert Banner

A prominent notification component for displaying important information or system status messages. Alert banners span the full width of their container and use distinctive colors to indicate message severity.

import {AlertBanner} from "@qualcomm-ui/react/alert-banner"

Examples

Simple

Use the simple API to create a banner using minimal markup.

Heading
Description
<AlertBanner
  action={
    <Button emphasis="white-persistent" size="sm" variant="outline">
      Action
    </Button>
  }
  description="Description"
  dismissable
  heading="Heading"
  onClose={() => console.log("close")}
/>

Composite

The composite API provides individual sub-components for custom layouts or when you need to render custom content within each slot.

Heading
Description
<AlertBanner.Root onClose={() => console.log("close")}>
  <AlertBanner.Icon />
  <AlertBanner.Heading>Heading</AlertBanner.Heading>
  <AlertBanner.Description>Description</AlertBanner.Description>
  <AlertBanner.ActionContainer>
    <Button emphasis="white-persistent" size="sm" variant="outline">
      Action
    </Button>
  </AlertBanner.ActionContainer>
  <AlertBanner.CloseButton />
</AlertBanner.Root>

Emphasis

The emphasis prop controls the banner's color scheme. The default is info. Each emphasis also determines the default icon.

info
success
warning
neutral
<AlertBanner emphasis="info" heading="info" />
<AlertBanner emphasis="success" heading="success" />
<AlertBanner emphasis="warning" heading="warning" />
<AlertBanner emphasis="danger" heading="danger" />
<AlertBanner emphasis="neutral" heading="neutral" />

Variant

The variant prop controls visual prominence. The default strong variant uses solid backgrounds for high visibility. The subtle variant uses muted backgrounds with borders.

info
success
warning
neutral
<AlertBanner emphasis="info" heading="info" variant="subtle" />
<AlertBanner emphasis="success" heading="success" variant="subtle" />
<AlertBanner emphasis="warning" heading="warning" variant="subtle" />
<AlertBanner emphasis="danger" heading="danger" variant="subtle" />
<AlertBanner emphasis="neutral" heading="neutral" variant="subtle" />

Dismissable

The banner is a controlled component. Set dismissable to render a close button, then handle visibility state via the onClose callback. With the composite API, use <AlertBanner.CloseButton />.

Simple API
Composite API
{simpleVisible && (
  <AlertBanner
    closeButtonAriaLabel="Close this banner"
    dismissable
    heading="Simple API"
    onClose={() => setSimpleVisible(false)}
  />
)}

{compositeVisible && (
  <AlertBanner.Root
    closeButtonAriaLabel="Close this banner"
    onClose={() => setCompositeVisible(false)}
    variant="subtle"
  >
    <AlertBanner.Icon />
    <AlertBanner.Heading>Composite API</AlertBanner.Heading>
    <AlertBanner.CloseButton />
  </AlertBanner.Root>
)}

Action

Pass a button to the action prop. Use size="sm" with emphasis="white-persistent" for strong banners, or emphasis="neutral" for subtle banners.

Strong
Use white-persistent emphasis for strong variant
Subtle
Use neutral emphasis for subtle variant
<AlertBanner
  action={
    <Button emphasis="white-persistent" size="sm" variant="outline">
      Take action
    </Button>
  }
  description="Use white-persistent emphasis for strong variant"
  heading="Strong"
  variant="strong"
/>

<AlertBanner
  action={
    <Button emphasis="neutral" size="sm" variant="outline">
      Take action
    </Button>
  }
  description="Use neutral emphasis for subtle variant"
  heading="Subtle"
  variant="subtle"
/>

API

<AlertBanner>

The AlertBanner component supports every property from the AlertBanner.Root component, plus the props listed below.

PropType
The component used for the content of the action element.
Props applied to the action container element.
Props applied to the close button element.
Optional description text for the banner.
Props applied to the description element.
When true, renders a close button that calls onClose when clicked.
boolean
Optional heading text for the banner.
Props applied to the heading element.
Override the icon displayed in the banner. When this prop is omitted, the icon is determined by the emphasis prop.
| LucideIcon
| ReactNode
Props applied to the icon element.
Description
The component used for the content of the action element.
Description
Props applied to the action container element.
Description
Props applied to the close button element.
Description
Optional description text for the banner.
Description
Props applied to the description element.
Type
boolean
Description
When true, renders a close button that calls onClose when clicked.
Description
Optional heading text for the banner.
Description
Props applied to the heading element.
Type
| LucideIcon
| ReactNode
Description
Override the icon displayed in the banner. When this prop is omitted, the icon is determined by the emphasis prop.
Description
Props applied to the icon element.

Composite API

<AlertBanner.Root>

Groups all parts of the alert banner. Renders a <div> element by default.
PropTypeDefault
React children prop.
Accessible label for the close button.
string
'Close'
The document's text/writing direction.
'ltr' | 'rtl'
'ltr'
Governs the color of the banner and its icon.
| 'info'
| 'success'
| 'warning'
| 'danger'
| 'neutral'
'info'
Callback fired when the close button is clicked.
    () => void
    Allows you to replace the component's HTML element with a different tag or component. Learn more
    | ReactElement
    | ((
    props: object,
    ) => ReactElement)
    The visual style of the banner.
    | 'strong'
    | 'subtle'
    'strong'
    
    Description
    React children prop.
    Type
    string
    Description
    Accessible label for the close button.
    Type
    'ltr' | 'rtl'
    Description
    The document's text/writing direction.
    Type
    | 'info'
    | 'success'
    | 'warning'
    | 'danger'
    | 'neutral'
    Description
    Governs the color of the banner and its icon.
    Type
    () => void
    Description
    Callback fired when the close button is clicked.
      Type
      | ReactElement
      | ((
      props: object,
      ) => ReactElement)
      Description
      Allows you to replace the component's HTML element with a different tag or component. Learn more
      Type
      | 'strong'
      | 'subtle'
      Description
      The visual style of the banner.

      <AlertBanner.Icon>

      An icon that indicates the banner's status. Renders a <span> element by default.
      PropType
      Override the icon displayed in the banner. When this prop is omitted, the icon is determined by the emphasis prop.
      | LucideIcon
      | ReactNode
      Allows you to replace the component's HTML element with a different tag or component. Learn more
      | ReactElement
      | ((
      props: object,
      ) => ReactElement)
      Type
      | LucideIcon
      | ReactNode
      Description
      Override the icon displayed in the banner. When this prop is omitted, the icon is determined by the emphasis prop.
      Type
      | ReactElement
      | ((
      props: object,
      ) => ReactElement)
      Description
      Allows you to replace the component's HTML element with a different tag or component. Learn more

      <AlertBanner.Heading>

      Heading of the alert banner. Renders a <div> element by default.
      PropType
      React children prop.
      Allows you to replace the component's HTML element with a different tag or component. Learn more
      | ReactElement
      | ((
      props: object,
      ) => ReactElement)
      Description
      React children prop.
      Type
      | ReactElement
      | ((
      props: object,
      ) => ReactElement)
      Description
      Allows you to replace the component's HTML element with a different tag or component. Learn more

      <AlertBanner.Description>

      Description of the alert banner. Renders a <div> element by default.
      PropType
      React children prop.
      Allows you to replace the component's HTML element with a different tag or component. Learn more
      | ReactElement
      | ((
      props: object,
      ) => ReactElement)
      Description
      React children prop.
      Type
      | ReactElement
      | ((
      props: object,
      ) => ReactElement)
      Description
      Allows you to replace the component's HTML element with a different tag or component. Learn more

      <AlertBanner.CloseButton>

      Calls the root's onClose when clicked. Renders a <button> element by default.
      PropType
      React children prop.
      Allows you to replace the component's HTML element with a different tag or component. Learn more
      | ReactElement
      | ((
      props: object,
      ) => ReactElement)
      Description
      React children prop.
      Type
      | ReactElement
      | ((
      props: object,
      ) => ReactElement)
      Description
      Allows you to replace the component's HTML element with a different tag or component. Learn more

      <AlertBanner.ActionContainer>

      A container for the banner's primary action button. Renders a <div> element by default.
      PropType
      React children prop.
      Allows you to replace the component's HTML element with a different tag or component. Learn more
      | ReactElement
      | ((
      props: object,
      ) => ReactElement)
      Description
      React children prop.
      Type
      | ReactElement
      | ((
      props: object,
      ) => ReactElement)
      Description
      Allows you to replace the component's HTML element with a different tag or component. Learn more