Skip to content

Lucky Draw

Interactive marketing component for e-commerce campaigns. It supports wheel and grid modes, custom prize rendering, and theme variable overrides.

Wheel Mode

Use type="wheel" to render a spinning prize wheel. When all prizes are pure text, the component automatically switches to its pure-text layout.

MacBook
MB
iPhone 15
IP
Gift Card
GC
No Prize
NP
10 Points
10P
Earphones
EP
JD Card
JD
Powerbank
PB
Start
Icons + Text
Grand Prize
1st Prize
2nd Prize
3rd Prize
No Prize
Lucky Prize
Try Again
Bonus Prize
Start
Pure Text Mode

Grid Mode

Use type="grid" to render a 3x3 lottery grid. The center area is the start button, and surrounding cells highlight in sequence until the target prize is reached.

MB
MacBook
IP
iPhone 15
GC
Gift Card
NP
No Prize
10P
10 Points
EP
Earphones
JD
JD Card
PB
Powerbank
Start
Grid Example

Usage in Nuxt

YhLuckyDraw can be used directly in Nuxt 3/4 projects. Static structure renders on the server, while the draw animation starts after the target prize id is provided on the client.

MacBook
MB
iPhone 15
IP
Gift Card
GC
No Prize
NP
10 Points
10P
Earphones
EP
JD Card
JD
Powerbank
PB
Start
Nuxt SSR Safety

SSR Notes:

  • The component's static layout can be rendered during SSR.
  • The actual draw animation starts only after target-id receives a valid value.
  • In normal usage, no extra <ClientOnly> wrapper is required.

API

Props

PropertyDescriptionTypeDefault
typeDraw mode'wheel' | 'grid''wheel'
prizesPrizes arrayLuckyPrize[][]
loadingAsync loading operation state mapping indicatorbooleanfalse
target-idOutcome ID (starts animation sequentially when resolved)string | number''
roundsMinimum rotationsnumber8
durationAnimation time (ms)number4000
sizeContainer bounds mappingnumber | string300
action-textAction button text overridestring''
hide-btnHide built-in buttonbooleanfalse
theme-overridesTheme variables object dictionaryRecord<string, string>{}

Events

Event NameDescriptionCallback Parameters
clickTriggered on component interaction phase, optimal for silent backend request chains(e: MouseEvent)
startTriggered precisely at absolute rotation begin()
finishFired when spinning concludes over resolved reward target(prize: LuckyPrize)

Slots

SlotDescriptionParameters
prizeCustom prize cell{ prize: LuckyPrize }
actionCustom start button area-

Expose

This component does not expose public instance methods or properties.

Theme Variables

Use the following theme variables to override the component's core visual styles:

Variable NameDescriptionDefault Standard
--yh-lucky-primaryPrimary accent color#ff4757
--yh-lucky-border-bgOuter container backgroundlinear-gradient(180deg, #ff8a65 0%, #ff5252 100%)
--yh-lucky-shadowOuter shadow0 10px 25px rgba(255, 82, 82, 0.3)

Type Exports

NameDescription
YhLuckyDrawPropsComponent props type
YhLuckyDrawEmitsComponent emits type
YhLuckyDrawSlotsComponent slots type
YhLuckyPrizePrize data type
YhLuckyDrawTypeDraw mode union
YhLuckyDrawInstanceComponent instance type

Released under the MIT License.