Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Overlays

  • Dialog
  • Modal
  • AlertDialog
  • Drawer
  • Popover
  • Tooltip
  • HoverCard
  • Glimpse
  • HeroVideoDialog
  • ElementSelectionOverlay

Messages

  • Alert
  • InterceptCard
  • Callout
  • Banner
  • Toast
  • Notification
  • ServiceMessage
  • Result
  • GiftFeed
  • FloatingReactions
  • Popconfirm

Loading and Progress

  • Spin
  • Spinner
  • Progress

Guidance

  • Tour

GiftFeed

gift-feed

Streams live gift events with sender, item, quantity, and combo emphasis.

Usage

Basic usage

Controlled incoming gift event stream (events array append), the component automatically merges with the id combo and plays the entry animation.

tsx
const [events, setEvents] = useState<GiftEvent[]>([]);
//Add an event when receiving a gift; the same id is passed in again → combo is incremented
// setEvents((p) => [...p, { id: "g1", user: { name: "Local Rich Brother" }, gift: { name: "Rocket", icon: "🚀" }, combo }]);

<GiftFeed events={events} />

Banner limit

max controls the number of banners on the screen at the same time (the oldest will be squeezed out if exceeded), only 1 is retained here.

tsx
<GiftFeed events={events} max={1} />

Length of stay

duration Controls the dwell milliseconds after a single banner has no new combos. After shortening, the banner will dissipate faster.

tsx
<GiftFeed events={events} duration={2000} />

When to use

Use GiftFeed in live or interactive experiences to show donation streak banners. Rapid gifts with the same id merge into combo ×N, reset the dismissal timer, and displace the oldest banner after the visible limit. This is a pointer-events:none effect layer above content. Use Result for general outcomes, Notification for ordinary messages, or pair it with FloatingReactions for floating likes.

Import

ts
import { GiftFeed, applyGiftEvent } from "@hulianui/ui"

Props

NameTypeDefaultDescription
events*GiftEvent[]-Append-only controlled stream. GiftEvent is {id, user:{name,avatar?}, gift:{name,icon?,color?}, combo?}; another event with the same id continues the streak.
maxnumber3Maximum simultaneously visible banners; the oldest is removed first.
durationnumber4000Milliseconds a banner remains after its last event.
classNamestring-Container class name.

applyGiftEvent is an exported pure function that merges an event into visible banners, increments or applies combo, and enforces max for isolated tests.

Example

tsx
const [events, setEvents] = useState<GiftEvent[]>([]);

function onGift(g: GiftEvent) {
  setEvents((prev) => [...prev.slice(-30), g]);
}

<div className="relative h-72 w-80">
  <GiftFeed events={events} max={3} duration={4000} className="w-full" />
</div>

Usage guidelines

  • events is append-stream data. Only an identical id continues a streak; give distinct gifts distinct ids to prevent accidental merging.
  • The caller maintains and increments combo; without it, the component counts appearances.
  • Bound the events array, as in .slice(-30), so a long-running stream does not grow indefinitely.
  • The banner's built-in Chinese verb is "\u9001\u51fa", meaning “sent.” It renders between the user name and gift name; supply already-localized user and gift content for an English experience.

Related

Alert · Banner · Toast · Notification · ServiceMessage · Result

PreviousResultFeedbackNextFloatingReactions

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Example
    • Usage guidelines
    • Related