Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Sales Notification

ProNew

Social proof in a corner: supplied purchases, stock alerts, bookings, reviews, follows and visitors appear as rotating notifications or a feed, with thumbnails, time and calls to action.

Installation

pnpm dlx shadcn@latest add @viewport/sales-notification

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
items*SalesNotificationItem[]

The events to show, in order. They come from your own store or backend; the component fetches nothing.

—
layout"toast" | "feed"

`toast` shows one event at a time in a corner; `feed` lists them all in the page.

"toast"
position"top-left" | "top-center" | "top-right" | "middle-left" | "middle-right" | "bottom-left" | "bottom-center" | "bottom-right"

Where the toast sits when there is room for it beside the content.

"bottom-left"
mobilePosition"top" | "bottom"

Where the toast sits on a narrow screen, where it spans the width.

"bottom"
anchor"viewport" | "parent"

`viewport` pins the toast to the window; `parent` to the nearest positioned ancestor.

"viewport"
shape"rounded" | "pill" | "square"

Corner style of the notification.

"rounded"
delaynumber

Seconds before the first notification.

3
durationnumber

Seconds each notification stays. Hovering or focusing it holds it.

6
intervalnumber

Seconds between two notifications.

4
loopboolean

Start over after the last event.

true
dismissibleboolean

Show the Close button and allow swiping the toast away; closing stops the cycle.

true
onDismiss() => void—
formatTime(date: Date) => string

Turns a date into the relative time label, for other languages.

—
live"polite" | "off"

Whether screen readers hear each notification as it arrives.

"polite"
labelstring

Names the region for assistive technology.

"Recent activity"
classNamestring—

Accessibility

  • The notifications sit in a named region that is a polite live region, so each one is read when it arrives without taking focus; set `live="off"` to keep it quiet.
  • Hovering or focusing a notification holds it on screen for as long as you need, and the cycle resumes when you leave.
  • The action is a link or a button, the Close button is named, and Escape closes the notification while focus is inside it; closing stops the cycle.
  • The thumbnail and badge are decoration unless you pass `imageAlt`, and a dated time is a `time` element with the exact moment.
  • Under reduced motion notifications swap immediately without fading, dragging or a pulsing visitor dot.