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

FloatingReactions

floating-reactions

Animates lightweight audience reactions upward over live content.

Usage

Imperative trigger

By ref.emit spraying floating emoticons, count fires multiple at once. Click the button to try it.

tsx
const ref = useRef<FloatingReactionsHandle>(null);

<Button onClick={() => ref.current?.emit("❤️", { count: 3 })}>Like ❤️</Button>
<FloatingReactions ref={ref} />

Random emoticon pool

When content is not transmitted, an emoticon is randomly selected from palette, which is suitable for mixed floating characters on the "like wall".

tsx
<Button onClick={() => ref.current?.emit(undefined, { count: 3 })}>Send flowers 🌸</Button>
<FloatingReactions ref={ref} palette={["🌸", "🌺", "🌷", "💐"]} />

Automatic burst

Call emit regularly to simulate the happy atmosphere of continuous likes in the live broadcast room.

tsx
useEffect(() => {
  const id = setInterval(() => ref.current?.emit(undefined, { count: 2 }), 500);
  return () => clearInterval(id);
}, []);

<FloatingReactions ref={ref} />

Larger font size

size Increase the base font size of individual expressions to make the overall expression more eye-catching.

tsx
<FloatingReactions ref={ref} size={40} />

When to use

Use FloatingReactions as an effect layer that emits hearts or other reactions upward from a like control. Call ref.emit() imperatively; each item randomizes its origin, drift, and scale, fades out, and removes itself. Use GiftFeed when gifts need streak merging and a counted banner.

Import

ts
import { FloatingReactions } from "@hulianui/ui"

Props

Access FloatingReactionsHandle through a ref and call emit(content?, opts?: { count?: number }); when content is absent, an entry is sampled from palette.

NameTypeDefaultDescription
paletteReactNode[]Heart setReaction pool used when emit has no content.
risenumber220Vertical travel in pixels.
driftnumber40Random horizontal travel in pixels.
durationnumber2200Animation duration in milliseconds.
sizenumber24Font size in pixels.
classNamestring-Container class name.

Example

tsx
const ref = useRef<FloatingReactionsHandle>(null);

<div className="relative h-72 w-64 overflow-hidden">
  <button onClick={() => ref.current?.emit("❤️", { count: 3 })}>Like ❤</button>
  <FloatingReactions ref={ref} />
</div>

Usage guidelines

  • Trigger through the ref's emit; no prop starts a burst. The containing element needs position:relative and usually overflow-hidden.
  • Reaction elements use pointer-events:none, so an overlay above a control does not intercept clicks.
  • No other known caveats.

Related

Alert · Banner · Toast · Notification · ServiceMessage · Result

PreviousGiftFeedFeedbackNextPopconfirm

On this page

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