Banner Overview

Banners are prominent messaging components used to communicate important information, alerts, or announcements to users at the page or section level. They provide aighly visible way to deliver critical messages, system status updates, or contextual information that requires immediate attention.

When to Use

Use banners when:

  • Displaying system-wide announcements or alerts
  • Communicating important status changes or updates
  • Showing temporary notifications that affect the entire interface
  • Providing feedback after user actions (success, warnings, errors)
  • Announcing new features, promotions, or important information
  • Displaying maintenance or service disruption notices

Don't use banners for:

  • Minor notifications (use toast notifications instead)
  • Persistent UI elements (use dedicated sections)
  • Form validation messages (use field-level feedback)
  • Marketing content that isn't critical (use cards or sections)
  • Information that doesn't require immediate attention
Design system docs Examples Default banner

The default banner uses the brand variant and includes an information icon:

The new version of the application is now available for download!
Banner variants

Different variants communicate different types of messages and urgency levels:

New Feature: Enhanced dashboard with real-time analytics is now available! System Update: Scheduled maintenance will occur tonight from 2:00 AM to 4:00 AM. Success: Your accountas been successfully verified and activated. Important: Your subscription expires in 7 days. Please renew to continue service. Service Disruption: We are experiencing technical difficulties. Our team is working on a fix.
Closeable banners

Allow users to dismiss banners by adding the closeable attribute. Listen to the dds-close event toandle the dismissal:

Tip: You can now save your work automatically. This banner can be dismissed. Reminder: Remember to backup your data regularly for safety.

####andling close events

document.querySelector('dap-ds-banner').addEventListener('dds-close', (event) => {
  //ide the banner
  event.target.opened = 'false';
  
  // Optional: Store dismissal state
  localStorage.setItem('banner-dismissed', 'true');
  
  console.log('Banner closed by user');
});
Banners with actions

Add interactive elements to banners using the actions slot. Actionselp users take immediate steps related to the banner message:

System Update Available: A new version with enhanced security features is ready to install. Install Now Learn More Storage Almost Full: You're using 85% of your available storage space. Upgrade Plan Manage Files Backup Complete: Your dataas been successfully backed up to the cloud. View Details
Custom icons

Customize banner icons using the icon attribute or the icon slot for more complex scenarios:

Download Ready: Your requested file is ready for download. Download Security Alert: We detected unusual activity on your account. Review Activity Premium Upgrade: You've been upgraded to our premium plan! Explore Features
Real-World Patterns System Status Banners
All Systems Operational: All services are running normally. Degraded Performance: Some users may experience slower response times. Status Page Service Outage: Authentication service is currently unavailable. Get Updates
Promotional Banners
Limited Time Offer: Get 30% off your first year with our annual plan! Claim Offer Learn More New Feature: Try our AI-powered analytics dashboard. Explore Now
Cookie and Privacy Notices
Cookie Notice: We use cookies to enhance your experience and analyze site usage. Accept All Customize Privacy Policy
Accessibility Features

Banners automatically include appropriate ARIA attributes and semantic roles:

  • Role: Banners use alert role for important messages
  • Live regions: Dynamic content changes are announced to screen readers
  • Keyboard navigation: Close buttons are fully keyboard accessible
  • Color contrast: All variants meet WCAG AA contrast requirements
Implementation Notes Banner Positioning

Banners are typically positioned at the top of pages or sections:

.page-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  margin-bottom: var(--dds-spacing-400);
}
Persistent vs Dismissible
  • Use persistent banners for critical system information
  • Make promotional or informational banners dismissible
  • Consider using session storage to remember dismissal state
Action Button Guidelines
  • Use primary buttons for the most important action
  • Limit to 2-3 actions maximum to avoid overwhelming users
  • Ensure action text is clear and specific to the banner context
Custom Styling

The banner component supports extensive customization beyond the default variants. This section demonstrates practical styling techniques and advanced customization patterns.

Quick Customization with CSS Custom Properties

For simple customizations, use CSS custom properties directly on the component:

Custom Styled Banner: This banner uses custom colors via CSS properties.
Advanced Styling with CSS Parts

Experiment with custom banner styling using CSS parts and custom properties. The banner component exposes several CSS parts for advanced styling: base, card-base, icon, icon-element, icon-base, closebutton, close-icon-element, close-icon-base, actions, and title. Try the presets below or create your own styles:

Select a presetElevated ShadowBorder AccentIcon StylingClose Button StylingGradient BackgroundRounded Corners
Copy CSSFormat CSSResetLightDark
CSS Editor
Live Preview

Custom Styled Banner: Experiment with different styling presets to see how CSS parts can customize the banner appearance. Action

Importing
import { DapDSBanner } from 'dap-design-system'
Importing React
import { DapDSBannerReact } from 'dap-design-system/react'
Tree-Shakeable Imports

For optimal bundle sizes, use the tree-shakeable import syntax:

import { DapDSBanner } from 'dap-design-system/components'
Attributes
PropertyTypeDefaultDescription
variant'brand', 'positive' , 'info' , 'warning' , 'negative''brand'The variant of the banner
closeablebooleanWhether the banner is closeable
openedstring'true'State of the banner. If false banner is hidden
closeButtonLabelstring'close'The aria-label for the close button
iconstringThe icon of the banner, this is a name of a built icon icon
Slots
NameDescription
(default)The content of the banner.
actionsActions of banner
iconThe icon of the banner.
Events
Event NameDescriptionType
dds-closeEvent fired when the banner is closed.{void }
CSS Parts
Part NameDescription
baseThe main banner container.
card-baseThe wrapper card container.
iconThe icon of the banner.
icon-elementThe icon element of the banner.
icon-baseThe base of the icon.
closebuttonThe close button of the banner.
close-icon-elementThe icon element of the close button.
close-icon-baseThe base of the close button icon.
actionsThe actions of the banner.
titleThe title of the banner.
How to Use CSS Parts

You can style CSS parts using the ::part() pseudo-element selector:

/* Target a specific part */
.my-custom-dap-ds-banner::part(base) {
  /* Your custom styles */
}

/* Target multiple parts */
.my-custom-dap-ds-banner::part(base),
.my-custom-dap-ds-banner::part(card-base) {
  /* Shared styles */
}

Example usage:

<dap-ds-banner class="my-custom-dap-ds-banner">
  Banner
</dap-ds-banner>
.my-custom-dap-ds-banner::part(base) {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

CSS parts allow you to style internal elements of the component while maintaining encapsulation. Learn more in our styling guide.

CSS Custom Properties
Property NameDescription
--dds-banner-gapThe gap between banner elements (default: var(--dds-spacing-200))
--dds-banner-line-heightThe line height of the banner text (default: var(--dds-font-line-height-xlarge))
--dds-banner-transitionThe transition property for the banner (default: all 0.2s ease-in-out)
--dds-banner-brand-backgroundThe background color of the brand banner (default: var(--dds-banner-background-brand))
--dds-banner-brand-icon-colorThe color of the brand banner icon (default: var(--dds-banner-icon-brand))
--dds-banner-brand-text-colorThe text color of the brand banner (default: var(--dds-banner-text-brand))
--dds-banner-brand-action-colorThe color of the brand banner actions (default: var(--dds-banner-action-enabled))
--dds-banner-info-backgroundThe background color of the info banner (default: var(--dds-banner-background-informative))
--dds-banner-info-icon-colorThe color of the info banner icon (default: var(--dds-banner-icon-informative))
--dds-banner-info-text-colorThe text color of the info banner (default: var(--dds-banner-text-informative))
--dds-banner-info-action-colorThe color of the info banner actions (default: var(--dds-banner-action-enabled))
--dds-banner-positive-backgroundThe background color of the positive banner (default: var(--dds-banner-background-positive))
--dds-banner-positive-icon-colorThe color of the positive banner icon (default: var(--dds-banner-icon-positive))
--dds-banner-positive-text-colorThe text color of the positive banner (default: var(--dds-banner-text-positive))
--dds-banner-positive-action-colorThe color of the positive banner actions (default: var(--dds-banner-action-enabled))
--dds-banner-warning-backgroundThe background color of the warning banner (default: var(--dds-banner-background-warning))
--dds-banner-warning-icon-colorThe color of the warning banner icon (default: var(--dds-banner-icon-warning))
--dds-banner-warning-text-colorThe text color of the warning banner (default: var(--dds-banner-text-warning))
--dds-banner-warning-action-colorThe color of the warning banner actions (default: var(--dds-banner-action-inverted-enabled))
--dds-banner-negative-backgroundThe background color of the negative banner (default: var(--dds-banner-background-negative))
--dds-banner-negative-icon-colorThe color of the negative banner icon (default: var(--dds-banner-icon-negative))
--dds-banner-negative-text-colorThe text color of the negative banner (default: var(--dds-banner-text-negative))
--dds-banner-negative-action-colorThe color of the negative banner actions (default: var(--dds-banner-action-inverted-enabled))
How to Use CSS Custom Properties

CSS custom properties (CSS variables) can be set directly on the component or in your stylesheet:

Method 1: Inline styles (Quick customization)

<dap-ds-banner
  style="--dds-banner-gap: value; --dds-banner-line-height: value;">
  Banner
</dap-ds-banner>

Method 2: CSS classes (Reusable styles)

.my-custom-dap-ds-banner {
  --dds-banner-gap: value;
  --dds-banner-line-height: value;
  --dds-banner-transition: value;
}
<dap-ds-banner class="my-custom-dap-ds-banner">
  Banner
</dap-ds-banner>

Method 3: Global theme customization

/* Apply to all instances */
dap-ds-banner {
  --dds-banner-gap: value;
  --dds-banner-line-height: value;
}

CSS custom properties inherit through the Shadow DOM, making them perfect for theming. Changes apply immediately without rebuilding.