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.
<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.
<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.
<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.
<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 />.
{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.
<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.
| Prop | Type |
|---|---|
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. | |
| LucideIcon | |
Props applied to the icon element. |
booleantrue, renders a close button that calls onClose when clicked.| LucideIcon
| ReactNode
Composite API
<AlertBanner.Root>
| Prop | Type | Default |
|---|---|---|
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' | '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 | |
The visual style of the banner. | | 'strong' | 'strong' |
string'ltr' | 'rtl'
| 'info'
| 'success'
| 'warning'
| 'danger'
| 'neutral'
() => void
| ReactElement
| ((
props: object,
) => ReactElement)
| 'strong'
| 'subtle'
<AlertBanner.Icon>
<span> element by
default.| Prop | Type |
|---|---|
| LucideIcon | |
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement |
| LucideIcon
| ReactNode
| ReactElement
| ((
props: object,
) => ReactElement)
| Attribute / Property | Value |
|---|---|
className | 'qui-alert-banner__icon' |
data-part | 'status-icon' |
data-scope | 'alert-banner' |
className'qui-alert-banner__icon'data-part'status-icon'data-scope'alert-banner'<AlertBanner.Heading>
<div> element by default.| Prop | Type |
|---|---|
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement |
| ReactElement
| ((
props: object,
) => ReactElement)
| Attribute / Property | Value |
|---|---|
className | 'qui-alert-banner__heading' |
data-part | 'heading' |
data-scope | 'alert-banner' |
className'qui-alert-banner__heading'data-part'heading'data-scope'alert-banner'<AlertBanner.Description>
<div> element by default.| Prop | Type |
|---|---|
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement |
| ReactElement
| ((
props: object,
) => ReactElement)
| Attribute / Property | Value |
|---|---|
className | 'qui-alert-banner__description' |
data-part | 'description' |
data-scope | 'alert-banner' |
className'qui-alert-banner__description'data-part'description'data-scope'alert-banner'<AlertBanner.CloseButton>
onClose when clicked. Renders a <button> element by default.| Prop | Type |
|---|---|
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement |
| ReactElement
| ((
props: object,
) => ReactElement)
| Attribute / Property | Value |
|---|---|
className | 'qui-alert-banner__close-button' |
data-part | 'close-button' |
data-scope | 'alert-banner' |
className'qui-alert-banner__close-button'data-part'close-button'data-scope'alert-banner'<AlertBanner.ActionContainer>
<div>
element by default.| Prop | Type |
|---|---|
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement |
| ReactElement
| ((
props: object,
) => ReactElement)
| Attribute / Property | Value |
|---|---|
className | 'qui-alert-banner__action' |
data-part | 'action' |
data-scope | 'alert-banner' |
className'qui-alert-banner__action'data-part'action'data-scope'alert-banner'
<div>element by default.