Skip to content

Banner

A slim bar across the top of a page for announcements and site-wide notices.

Shared views are here. Read the announcement

You’re viewing the docs for version 1.

Projects will be read-only on Saturday from 02:00 to 03:00 UTC.

Your account is verified.

You’ve used 9.2 of 10 GB of storage.

Deployments are failing. Check the status page

Installation

  1. Add the registryOnce per project
  2. 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.

Shared views are here. Read the announcement

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.

Your trial ends in 3 days.

Props

Base UI's styling (opens in a new tab) and composition (opens in a new tab) guides say more about className, style and render.

BannerContent

BannerClose