Alert component overview
When to use
Use alerts when
- You need to clearly and concisely convey important information
- A message applies to a page, card, section, or system-level state
- Users need feedback after submitting data, changing permissions, or completing an action
- Users need to know about errors, warnings, maintenance, upgrades, or time-sensitive tasks
Do not use alerts when
- The alert would disrupt a critical task
- The message overlaps essential content or important interface controls
- Its presence could confuse users or compete with a more relevant inline message
- A toast, notification, or field-level validation message would be more precise
Patterns
Alerts can be used at different scopes, depending on what the message affects.Anatomy
Alert component anatomy
Design guidelines
Types
Set
border to match the surface where the alert appears. Use the same radius scale as the surrounding layout.Usage
Default
Use thedefault variant for general-purpose alerts. It lets you customize the bq-icon for messages with no associated severity.
Info
Use theinfo variant when users need additional, non-critical information. It works well for context that helps users understand a state without requiring immediate action.
Success
Use thesuccess variant to notify users about successful actions or positive outcomes. This type of alert is ideal for celebrating achievements, completed processes, or any operation that concludes successfully.
Warning
Use thewarning variant to indicate potential issues or actions that users should approach with caution. This alert helps draw attention to situations that require careful consideration but may not be critical.
Error
Use theerror variant for issues that require immediate attention. It works best for problems that block the task or prevent a successful outcome.
Options
Sticky
Use thesticky attribute for persistent alerts that remain visible until users dismiss them. Sticky alerts work well for ongoing information that needs prolonged attention, such as system updates or maintenance notices.
Auto-dismiss
Setauto-dismiss to hide the alert automatically after a delay. Use time to override the default 3000 ms. Set a minimum of 8000 ms for alerts with meaningful content so users have enough time to read the message.
Best practices
DoPlace alerts close to the content or workflow they affect.
Don’tDo not place alerts where they hide controls or interrupt a critical task.
DoWrite a short title that explains the state, then add body text only when users need context.
Don’tDo not use long paragraphs or unrelated links inside an alert.
DoGive users enough time to read auto-dismiss alerts and keep important messages dismissible by intent.
Don’tDo not auto-dismiss alerts that contain errors, required actions, or legal information.
DoMatch the alert type, icon, and action style to the severity of the message.
Don’tDo not mix severity colors or custom icons in ways that make the alert harder to scan.
Accessibility
- The host uses
role="alert"so assistive technologies announce the message when it appears. - The host sets
aria-hiddenfrom theopenstate, keeping hidden alerts out of the accessibility tree. - The default close button has the accessible label “Close alert.”
typeprovides visual intent and a matching predefined status icon forinfo,success,warning, anderror.- Provide a concise title in the default slot and supporting details in the
bodyslot when users need more context. - The built-in type tokens (
info,success,warning,error) meet WCAG AA color-contrast requirements in both light and dark themes. Verify contrast manually when using custom colors via CSS variables. - All interactive elements inside the alert — the close button, footer actions, and body links — must be reachable via
Taband have a visible focus indicator. - Set
timeto a minimum of 8000 ms forauto-dismissalerts. Do not auto-dismiss while the user has keyboard focus or hover inside the alert. - When
stickyis enabled, keep the page focus order logical so keyboard users can still reach the affected content.
API reference
Properties
Events
- In React, prefix events with
on:onBqShow,onBqHide,onBqAfterShow,onBqAfterHide. - In Angular, use the event binding syntax:
(bqShow),(bqHide),(bqAfterShow),(bqAfterHide). - In Vue, use the
@shorthand:@bqShow,@bqHide,@bqAfterShow,@bqAfterHide.
Methods
Slots
Shadow parts
CSS custom properties
Resources
Use Storybook to test behavior and states interactively, or review the source if you need implementation details.Interactive playground
Explore all alert configurations in Storybook
Source code
View the component source on GitHub