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

Collections

  • QuestionCard
  • Table
  • Book3D
  • ProTable
  • PricingTable
  • JsonViewer
  • EditableTable
  • List
  • Descriptions
  • RowActions
  • Tree
  • Card
  • Carousel
  • Video
  • Audio
  • BentoGrid
  • Image
  • MagicCard
  • AnimatedList
  • Marquee
  • Sortable
  • Kanban
  • DesignCanvas
  • LayerTree
  • StageDraw
  • SlideDeck
  • PresenterView
  • ComponentPicker
  • EventStream
  • QueueLane
  • DocumentSheet
  • Novel reader
  • Scheduler
  • Org classroom
  • Danmaku
  • LiveChat
  • LivePlayer
  • LogViewer
  • FileTree
  • CodeReviewThread
  • VirtualList
  • InfiniteScroll
  • LogoLoop
  • BounceCards
  • CardSwap
  • ChromaGrid
  • CircularGallery
  • DomeGallery
  • FlyingPosters
  • InfiniteMenu
  • MagicBento
  • ScrollStack
  • ProfileCard
  • TiltedCard
  • PixelCard
  • DecayCard
  • ReflectiveCard
  • Folder

Charts and Diagrams

  • Flow
  • Diagram
  • Paper
  • SequenceDiagram
  • Sankey
  • Sparkline
  • Funnel
  • Treemap
  • Gantt
  • Heatmap
  • ContributionGraph
  • Legend
  • Chart
  • WorldMap

Information

  • ImageViewer
  • LiveProductCard
  • DiffStat
  • ScoreRing
  • ScoreScale
  • Badge
  • Dot
  • StatusDot
  • Chip
  • FilterChip
  • Coupon
  • Tag
  • Annotation
  • Avatar
  • AvatarCircles
  • User
  • QRCode
  • Comment
  • RelativeTime
  • GitCommit
  • DeployStatus
  • ShieldBadge
  • AwardBadge
  • CreditCard
  • IconTile

Metrics

  • Stat
  • Statistic
  • Meter
  • Timeline
  • NumberTicker

Placeholders

  • Empty
  • Skeleton
  • Watermark

Danmaku

danmaku

Overlays lane-allocated scrolling, top, or bottom audience comments on media.

Usage

Basic usage

The barrage layer superimposed on the video (absolute inset-0). items is controlled and can only be added but not modified. New items are automatically entered and tracked to prevent overlapping and drifting.

Live screen
tsx
<div className="relative aspect-video">
  <video ... />
  <Danmaku
    items={[
      { id: "x1", text: "Barrage passing~" },
      { id: "x2", text: "The anchor is so cool!", color: "var(--color-chart-1)", bold: true },
    ]}
    tracks={4}
    speed={100}
  />
</div>

Top stay barrage

The barrage of mode='top' stays at the top for a period of time (non-scrolling), suitable for announcements/sticking.

Live screen
tsx
<Danmaku
  items={[
    { id: "y0", text: "The draw will be held at 8 o'clock tonight, pay attention to not get lost", mode: "top", bold: true },
    { id: "y1", text: "Front row watching" },
  ]}
  tracks={4}
/>

High Density · Fast

density='high' is forced to squeeze even if there is no free track (no barrages are lost); speed speeds up, tracks adds tracks.

Live screen
tsx
<Danmaku items={items} density="high" speed={160} tracks={6} />

When to use

Use Danmaku over a livestream or video, commonly in LivePlayer's overlay. Use LiveChat for a scrolling public message list.

Import

ts
import { Danmaku, allocateTrack, densityGap, estimateWidth, leastBusyTrack, scrollDuration, trackFreeTime } from "@hulianui/ui"

Props

NameTypeDefaultDescription
items*DanmakuItem[]-Controlled append-only stream; unseen ids enter once.
tracksnumber4Scrolling tracks.
speednumber100Speed in pixels per second.
density"low" | "normal" | "high""normal"Safety gap and overflow pressure.
areanumber1Used height ratio from 0 to 1.
opacitynumber1Overall opacity.
pausedbooleanfalsePauses all animations.
classNamestring-Container class.

DanmakuItem

NameTypeDefaultDescription
id *string-Deduplication key: it decides whether an item has already entered, so only unseen ids animate in.
text *ReactNode-Comment content.
mode"scroll" | "top" | "bottom""scroll"Scrolling, pinned to the top, or pinned to the bottom.
colorstringInherits the foreground tokenText color.
size"sm" | "md" | "lg""md"Font size preset.
boldbooleanfalseBold text.

Usage notes

  • Editing an existing id does not replay it; assign a new id.
  • Trim long-running streams to bound memory.
  • The parent needs relative positioning and hidden overflow. Danmaku fills it with pointer events disabled.
  • Width estimation for non-string content uses the runtime fallback "\u5f39\u5e55\u5f39\u5e55\u5f39\u5e55" (three repetitions of "bullet comment") as a medium-width sample; it is not rendered to users.

Related

Table · Book3D · ProTable · PricingTable · JsonViewer · EditableTable

Playground

Live screen
<div className="relative aspect-video">
  <video ... />
  <Danmaku items={items} tracks={4} speed={100} density="normal" />
</div>
PreviousImageViewerData DisplayNextLiveChat

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Usage notes
    • Related
  • Playground