Dice UI

Banner

A notification banner that appears at the top or bottom of the viewport. Supports queuing, priority, and auto-dismiss.

API

Installation

pnpm dlx shadcn@latest add "@diceui/banner"

Layout

import {
  Banner,
  BannerIcon,
  BannerContent,
  BannerTitle,
  BannerDescription,
  BannerActions,
  BannerClose,
} from "@/components/ui/banner";
 
return (
  <Banner>
    <BannerIcon />
    <BannerContent>
      <BannerTitle />
      <BannerDescription />
    </BannerContent>
    <BannerActions />
    <BannerClose />
  </Banner>
);

Examples

Stacked Banners

Use the Banners provider to manage multiple banners with a queue system. Banners can be added imperatively using the useBanners hook.

API Reference

Banners

The root provider for managing a queue of banners. Wrap your application or a section to enable banner queuing.

Prop

Type

Data AttributeValue
[data-side]"top" | "bottom"

An individual banner component. Can be used standalone or within the Banners provider.

Prop

Type

Data AttributeValue
[data-state]"open" | "closed"

BannerIcon

Container for the banner's icon.

Prop

Type

BannerContent

Container for the banner's text content (title and description).

Prop

Type

BannerTitle

The banner's title text.

Prop

Type

BannerDescription

The banner's description text.

Prop

Type

BannerActions

Container for action buttons.

Prop

Type

BannerClose

A button that dismisses the banner. Uses the shadcn Button component internally.

Prop

Type

useBanners

Hook to access banner queue management within a Banners provider.

Prop

Type

useBanner

Hook to access the current banner's context (id, variant, dismissible state, and close handler).

Prop

Type

Accessibility

Keyboard Interactions

KeyDescription
TabMoves focus to the next focusable element within the banner.
ShiftTabMoves focus to the previous focusable element within the banner.
EnterActivates the focused button.
SpaceActivates the focused button.

On this page