TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/shuding/nextra/llms.txt
Use this file to discover all available pages before exploring further.
Banner component renders a fixed, dismissible announcement strip at the top of the page. It is ideal for announcing new releases, upcoming maintenance, or any time-sensitive notice you want every visitor to see. Once a user dismisses the banner, the decision is stored in localStorage under a configurable key — changing that key causes the banner to reappear for all visitors, making it easy to manage multiple sequential announcements.
Import
Props
| Prop | Type | Default | Description |
|---|---|---|---|
storageKey | string | 'nextra-banner' | The localStorage key used to remember whether the banner has been dismissed. Change this value whenever you update the banner content so that it reappears for returning visitors. |
dismissible | boolean | true | When true, a close (×) button is rendered. Set to false to make the banner permanent. |
children | ReactNode | — | The content rendered inside the banner. Supports links and inline markup. |
className | string | — | Additional CSS class names applied to the inner content wrapper. |
Usage
Basic Banner
Non-Dismissible Banner
Setdismissible={false} to hide the close button and keep the banner visible at all times — useful for mandatory notices such as a site-wide outage or a required migration warning.
Using Banner in a Layout
The most common usage is to pass theBanner as a prop to the docs theme Layout component inside your root app/layout.tsx. This ensures it appears on every page of the site without having to add it to individual MDX files.
Updating Banner Content
Every time you change the text of your banner, updatestorageKey to a new descriptive value. Visitors who dismissed the previous banner will see the new one because the old dismissed state is stored under a different key.
How Dismissal Works
When the user clicks the close button, the component writes thestorageKey value to localStorage. On subsequent page loads, an inline <script> (injected before hydration) reads localStorage and immediately toggles the x:hidden class on the banner element, preventing any flash of the banner before React hydrates.
Because the dismiss state lives in
localStorage, it is browser-specific and not shared across devices. Clearing browser data or using a different browser will cause the banner to reappear.CSS Custom Property
TheBanner component automatically sets the --nextra-banner-height CSS custom property on the <html> element via a ResizeObserver. The docs theme uses this value to offset the sticky header so it doesn’t overlap the banner.
If you are building a custom theme or layout, you can read this property to position fixed elements correctly: