Alert Banner
1.12.0A 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={<AlertBanner.Button>Action</AlertBanner.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.Button>Action</AlertBanner.Button>
<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
action={<AlertBanner.Button>Action</AlertBanner.Button>}
description="Description"
emphasis="info"
heading="info"
/>
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
action={<AlertBanner.Button>Action</AlertBanner.Button>}
description="Description"
emphasis="info"
heading="info"
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
The <AlertBanner.Button> was added in v1.21.0 and should be used instead of the <AlertBanner.ActionContainer> component.
Pass an <AlertBanner.Button> instance to the action prop.
<AlertBanner
action={<AlertBanner.Button>Take action</AlertBanner.Button>}
heading="Strong"
variant="strong"
/>
<AlertBanner
action={<AlertBanner.Button>Take action</AlertBanner.Button>}
heading="Subtle"
variant="subtle"
/>
Explorer
Component Anatomy
Hover to highlight, click to view API
API
<AlertBanner>
The AlertBanner component supports every property from the AlertBanner.Root component, plus the props listed below.
booleantrue, renders a close button that calls onClose when clicked.| LucideIcon
| ReactNode
Composite API
<AlertBanner.Root>
string'ltr' | 'rtl'
| 'info'
| 'success'
| 'warning'
| 'danger'
| 'neutral'
() => void
| ReactElement
| ((
props: object,
) => ReactElement)
| 'strong'
| 'subtle'
<AlertBanner.Icon>
<span> element by
default.| LucideIcon
| ReactNode
| ReactElement
| ((
props: object,
) => ReactElement)
className'qui-alert-banner__icon'data-alert-banner-part'status-icon'<AlertBanner.Heading>
<div> element by default.| ReactElement
| ((
props: object,
) => ReactElement)
className'qui-alert-banner__heading'data-alert-banner-part'heading'<AlertBanner.Description>
<div> element by default.| ReactElement
| ((
props: object,
) => ReactElement)
className'qui-alert-banner__description'data-alert-banner-part'description'<AlertBanner.CloseButton>
onClose when clicked. Renders a <button> element by default.| ReactElement
| ((
props: object,
) => ReactElement)
className'qui-alert-banner__close-button'data-alert-banner-part'close-button'<AlertBanner.Button>
AlertBanner.ActionContainerbooleantrue, pointer/focus
events are blocked, and the component is visually dimmed.| LucideIcon
| ReactNode
LucideIcon, the size will automatically match the size prop.
Supply as a ReactElement for additional customization.| ReactElement
| ((
props: object,
) => ReactElement)
className'qui-alert-banner__action'data-alert-banner-part'action'data-button-part'root'data-density| 'default'
| 'compact'
data-disableddata-kind'text'data-size| 'sm'
| 'md'
| 'lg'
data-variant| 'fill'
| 'ghost'
| 'outline'
<AlertBanner.ActionContainer>
<div>
element by default.| ReactElement
| ((
props: object,
) => ReactElement)
className'qui-alert-banner__action'data-alert-banner-part'action'
<div>element by default.