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

StageDraw

stage-draw

Lightweight transparent overlay for presentation annotations, fading laser pointer, and click-through pass-through.

Usage

Floating Toolbar & Click-Through Verification

Mount StageDraw over a slide: sketch with pen/highlighter, guide focus with laser, erase strokes, and switch back to pass-through to click buttons underneath.

Q4 Product Growth ReviewSlide 3 / 12
Monthly Active Users
128.4k
+24.6%
Paid Conversion
6.8%
+1.2pt
Net Retention
118%
Key Metric
Switch to Pass-through mode to click the slide button below
tsx
<div className="relative h-[300px]">
  <SlideContent />
  <StageDraw tool={tool} onToolChange={setTool} toolbar />
</div>

External Controls & Laser Pointer Demo

Disable the built-in toolbar and drive StageDraw with controlled tool and apiRef; the laser leaves a glowing trail that fades out over 750ms without persisting strokes.

Q4 Product Growth ReviewSlide 3 / 12
Monthly Active Users
128.4k
+24.6%
Paid Conversion
6.8%
+1.2pt
Net Retention
118%
Key Metric
Switch to Pass-through mode to click the slide button below
tsx
<StageDraw tool={tool} apiRef={apiRef} laserDecayMs={750} />

When to Use

Place StageDraw over slide decks, full-screen presentations, dashboards, or teaching stages so presenters can circle key metrics, highlight text, or guide audience attention with a laser pointer. When tool="none", the overlay applies pointer-events-none so clicks, hovers, and controls underneath remain completely unobstructed.

  • For freeform rectangle layout with infinite pan and zoom, use DesignCanvas.
  • For proportional big-screen scaling without annotation, use FitScreen.

Import

ts
import {
  StageDraw,
  normalizePoint,
  strokeToSvgPath,
  hitTestStroke,
  pruneLaserPoints,
} from "@hulianui/ui"

Props

NameTypeDefaultDescription
tool"none" | "pen" | "highlighter" | "laser" | "eraser""none"Active drawing tool; "none" lets all pointer events pass through to underlying content
strokesStageDrawStroke[]—Controlled strokes array; updates are reported via onStrokesChange
defaultStrokesStageDrawStroke[][]Initial strokes when used uncontrolled
onStrokesChange(strokes: StageDrawStroke[]) => void—Called whenever strokes are drawn, erased, undone, redone, or cleared
colorstring"#ef4444"Stroke color for pen and highlighter (CSS color or variable)
strokeWidthnumber3Reference pen stroke width in pixels; highlighter defaults to strokeWidth * 5
highlighterOpacitynumber0.35Opacity applied to highlighter strokes (0 to 1)
laserColorstring"#ef4444"Glow and trail color for the laser pointer
laserDecayMsnumber750Decay duration in milliseconds for laser trail points (recommended 600 to 1000)
eraserRadiusnumber0.025Normalized hit-test distance threshold used by the eraser tool
toolbarbooleanfalseRenders a compact floating toolbar at the bottom; stays pointer-events-auto even when tool="none"
onToolChange(tool: StageDrawTool) => void—Called when a tool is selected from the built-in toolbar
onColorChange(color: string) => void—Called when a color swatch is selected from the built-in toolbar
presetColorsstring[]["#ef4444", "#f59e0b", "#22c55e", "#3b82f6", "#8b5cf6"]Preset color swatches shown in the built-in toolbar
disabledbooleanfalseDisables drawing and toolbar interactions while allowing pointer pass-through
apiRefMutableRefObject<StageDrawApi | null>—Imperative handle exposing undo, redo, clear, canUndo, and canRedo
labelsPartial<StageDrawLabels>Built-in defaultsOverrides accessible labels and toolbar tooltips
classNamestring—Outer overlay container class name (defaults to absolute inset-0; pass fixed inset-0 for full-viewport overlays)

StageDrawStroke

NameTypeDefaultDescription
id*string—Unique stroke identifier
tool*"pen" | "highlighter"—Stroke tool type
color*string—Stroke color
width*number—Reference stroke width in pixels
opacitynumber1 for pen, 0.35 for highlighterStroke opacity
points*StageDrawPoint[]—Sequence of normalized points

StageDrawPoint

NameTypeDefaultDescription
x*number—Normalized X coordinate in [0, 1] relative to overlay width
y*number—Normalized Y coordinate in [0, 1] relative to overlay height
pressurenumber—Optional normalized pointer pressure in [0, 1]

StageDrawLaserPoint

NameTypeDefaultDescription
x*number—Normalized X coordinate in [0, 1]
y*number—Normalized Y coordinate in [0, 1]
t*number—Sample timestamp in milliseconds

StageDrawRect

NameTypeDefaultDescription
left*number—Container left offset in pixels
top*number—Container top offset in pixels
width*number—Container width in pixels
height*number—Container height in pixels

StageDrawApi

NameTypeDefaultDescription
undo*() => void—Reverts the last stroke mutation
redo*() => void—Reapplies the last undone mutation
clear*() => void—Clears all strokes (undoable)
canUndo*() => boolean—Returns whether undo history is available
canRedo*() => boolean—Returns whether redo history is available

StageDrawLabels

NameTypeDefaultDescription
stage*stringBuilt-in defaultAccessible name for the overlay and toolbar
none*stringBuilt-in defaultLabel for pass-through cursor mode
pen*stringBuilt-in defaultLabel for pen tool
highlighter*stringBuilt-in defaultLabel for highlighter tool
laser*stringBuilt-in defaultLabel for laser pointer tool
eraser*stringBuilt-in defaultLabel for eraser tool
undo*stringBuilt-in defaultLabel for undo action
redo*stringBuilt-in defaultLabel for redo action
clear*stringBuilt-in defaultLabel for clear action

Pure Utilities

  • normalizePoint(clientX, clientY, rect, pressure?): converts viewport coordinates into clamped [0, 1] normalized coordinates.
  • strokeToSvgPath(points, width, height): converts normalized points into a smooth quadratic Bezier SVG path string.
  • hitTestStroke(stroke, point, threshold): tests whether a normalized point lies within threshold distance of any stroke segment.
  • pruneLaserPoints(points, now, decayMs): drops laser trail points older than decayMs.

Pitfalls

  • StageDraw uses absolute inset-0 by default, so wrap your presentation container in relative (or pass className="fixed inset-0 z-50" for viewport-wide annotation).
  • Laser pointer trails (tool="laser") are strictly ephemeral: they never mutate strokes or fire onStrokesChange, and the internal requestAnimationFrame loop automatically stops once the trail finishes decaying so idle CPU usage stays at zero.

Related

DesignCanvas · FitScreen

Playground

Q4 Product Growth ReviewSlide 3 / 12
Monthly Active Users
128.4k
+24.6%
Paid Conversion
6.8%
+1.2pt
Net Retention
118%
Key Metric
Switch to Pass-through mode to click the slide button below
<StageDraw tool="pen" strokeWidth={3} toolbar />
PreviousLayerTreeData DisplayNextSlideDeck

On this page

  • Usage
  • Documentation
    • When to Use
    • Import
    • Props
    • Pure Utilities
    • Pitfalls
    • Related
  • Playground