Skip to content
NewYour data: charts, lists and meters that take your records
<px-bell>Custom elementMoments

Notification bell

Pixel notification bell that swings with a lagging clapper and pops its badge on new items; clicking it clears the badge in a spray of pixels.

View as Markdown
<px-bell>

Your data

Pass the unread count as count and call notify() or clearAll(). Without it the bell starts at 2 unread. See Your data.

Playground

Change a prop and the component updates. Props marked live animate to the new value; the others rebuild the element.

Loading <px-bell>
Props
countlive
<PxBell count={2} />

Installation

pnpm dlx shadcn@latest add @lumesec/px-bell
First timeRegister the @lumesec registry once, or install by URL

Adds @lumesec to your components.json:

pnpm dlx shadcn@latest registry add @lumesec=https://elements.lumesec.ai/r/{name}.json

Or skip the setup and install by URL:

npx shadcn@latest add https://elements.lumesec.ai/r/px-bell.json

Usage

import { PxBell } from "@/components/lumesec/px-bell";

export function Example() {
  return (
    <PxBell count={2} />
  );
}

Behaviour

A new notification swings the bell on its pivot with a lagging clapper, sends sound waves out both sides and pops the badge. Clicking the bell clears it in a spray of pixels.

API reference

Attributes

countReact propcountTypenumberDefault2

Unread count, rounded to a whole number of at least 0. Changing it updates the count without ringing the bell.

Events

Events bubble and cross the shadow boundary unless the description says otherwise.

notifyReact proponNotifyDetail{ unread: number }

Fires on each new notification with the new unread count.

readReact proponReadDetail{}

Fires when everything is marked as read, from a click on the bell or from clearAll().

Methods

Call them on the element, for example through a React ref.

notify()

Adds one unread notification, rings the bell and fires notify.

clearAll()

Marks everything as read and fires read. Does nothing when the count is already zero.

Accessibility

  • The bell is a native button whose aria-label includes the count ("Notifications, 2 unread. Mark all as read" or "Notifications, all caught up").
  • The "N unread" / "All caught up" text is an aria-live="polite" region.
  • "Notify" is a native button.
  • Reduced motion: the bell and clapper do not swing and the clearing sparks are skipped; the sound waves and badge pop still play.

Theming

The element reads your shadcn theme tokens through its shadow root, so light and dark follow your theme. The accent comes from --lumesec. See Theming.

This component reads --foreground and --lumesec.

To restyle only LumeSec elements, set the matching --ui-* overrides: --ui-accent and --ui-fg.

Notes

  • The badge count is drawn in the monospace font and shows 9+ above nine. The bell canvas is a fixed 180 by 116px.

Was this page helpful?