- Add the registry
- Add banner
Usage
Render the banner first in the page, above the site's header, so it spans the full width. It scrolls away with the page, and a Scroll Header after it sticks to the top once the banner is out of view. For a message inside the page's content, use an Alert instead.
An icon placed before BannerContent sits beside the text, and the text stays centered. Links in
BannerContent are underlined to match the banner's colors.
Banner renders a <section> labeled "Notice", so screen reader users can find it among the page's
landmarks. Pass an aria-label that describes your banner, such as "Announcement". Screen readers
don't announce the banner when it appears. For a message that responds to something someone did,
use a Toast.
Composition
Examples
Dismissible
BannerClose renders an icon button labeled "Dismiss" at the banner's end. It doesn't hide the
banner by itself, so you decide what dismissing does. Pass aria-label to change its label.
To keep a banner hidden after someone dismisses it, save the choice in local storage or on your server. Read the saved choice in an effect so server-rendered pages don't flash the banner.
With a button
Place a small Button after BannerContent for the banner's main action.