Prize Wheel Opt-in 1
Prize-wheel opt-in: every slice is a real supplied reward, set out as a scoreboard. The visitor enters an email and spins, then the board lights the reward and reveals its code.
Use it in a prompt
Use attention/prize-wheel-optin from the FunnelDNA library. Follow the skill and theme contract. Ask me for the copy, images, and brand details you need; do not invent proof.
Paste into Claude or ChatGPT with FunnelDNA connected (MCP setup), or alongside the skill.
Use it in code
- Save
component.tsx(Code tab) ascomponents/funneldna/attention/prize-wheel-optin.tsx. - Import it and pass your copy and images (Props tab):
import { PrizeWheelOptin } from "@/components/funneldna/attention/prize-wheel-optin"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/attention/prize-wheel-optin/component.tsx 567 lines
// layout: fact-scoreboard
// Prize-wheel opt-in: every slice is a real supplied reward, set out as a scoreboard. The visitor enters an email and spins, then the board lights the reward and reveals its code.
import React, { useEffect, useId, useMemo, useRef, useState } from 'react'
import { Check, Copy, Gift, Loader2, Lock, ShieldCheck, X } from 'lucide-react'
export type PrizeWheelPrize = {
/** Big scoreboard figure, e.g. '15%' or '$29' */
value: string
/** What the reward is, e.g. 'off your first order' */
label: string
/** Short text on the wheel slice, two words at most (defaults to value) */
wheelLabel?: string
/** Code revealed when the wheel lands on this reward */
code?: string
/** item-n slot image of the reward */
image?: string
imageAlt?: string
}
export type PrizeWheelOptinProps = {
headline?: string
/** Phrase inside the headline swiped with the marker */
highlight?: string
lead?: string
/** Every outcome the wheel can land on. The wheel shows exactly these and nothing else */
prizes?: PrizeWheelPrize[]
/** Accessible name of the reward list */
prizesLabel?: string
/** Line under the wheel */
wheelNote?: string
/** Accessible wheel description. {rewards} becomes the list of rewards */
wheelAriaLabel?: string
emailLabel?: string
emailPlaceholder?: string
spinLabel?: string
spinningLabel?: string
reassurance?: string
invalidEmail?: string
submitError?: string
/** Heading after landing. {reward} becomes the slice landed on */
landedTitle?: string
/** Flag on the lit scoreboard tile */
landedFlag?: string
codeLabel?: string
copyLabel?: string
copiedLabel?: string
codeNote?: string
claimLabel?: string
declineLabel?: string
closeLabel?: string
reopenLabel?: string
/** inline sits in a section. drawer slides in from the left over the page */
presentation?: 'inline' | 'drawer'
/** Controlled open state. Omit it and the piece manages close and reopen itself */
open?: boolean
/** Validated email. May return the prize index to land on; otherwise one is drawn at random from prizes */
onSubmit?: (values: { email: string }) => void | number | Promise<void | number>
/** Claim click after landing */
onAction?: (prize: PrizeWheelPrize, index: number) => void
href?: string
onClose?: () => void
onOpen?: () => void
state?: 'default' | 'hover' | 'active' | 'disabled' | 'error' | 'success'
className?: string
}
const DEFAULT_PRIZES: PrizeWheelPrize[] = [
{ value: '10%', label: 'off your first order', wheelLabel: '10% off' },
{ value: 'Free', label: 'shipping on your order', wheelLabel: 'Free shipping' },
{ value: 'Bonus', label: 'guide sent with your order', wheelLabel: 'Bonus guide' },
]
const EMAIL = /^[^@ ]+@[^@ ]+[.][^@ .]+$/
type Phase = 'idle' | 'pending' | 'spinning' | 'landed'
export function PrizeWheelOptin(props: PrizeWheelOptinProps) {
const {
headline = 'Spin once. Every slice is a real reward.',
highlight = 'Every slice is a real reward.',
lead = 'Enter your email, spin the wheel, and keep whatever you land on.',
prizesLabel = 'Rewards on the wheel',
wheelNote = 'No empty slices. Every outcome is listed here.',
wheelAriaLabel = 'Prize wheel. It can land on: {rewards}.',
emailLabel = 'Email address',
emailPlaceholder = 'you@example.com',
spinLabel = 'Spin & send my reward',
spinningLabel = 'Spinning…',
reassurance = 'Just your email. No card, no catch.',
invalidEmail = 'Enter a valid email so we can send your reward.',
submitError = 'We couldn’t start your spin. Please try again.',
landedTitle = 'You landed on {reward}',
landedFlag = 'Your reward',
codeLabel = 'Your code',
copyLabel = 'Copy code',
copiedLabel = 'Copied',
codeNote = 'Paste it at checkout to use your reward.',
claimLabel = 'Use my reward now',
declineLabel = 'No thanks, I’ll skip my reward',
closeLabel = 'Close',
reopenLabel = 'Your spin is waiting',
presentation = 'inline',
open,
onSubmit,
onAction,
href,
onClose,
onOpen,
state = 'default',
className,
} = props
const prizes = props.prizes && props.prizes.length > 0 ? props.prizes : DEFAULT_PRIZES
const segments = useMemo(() => {
const reps = prizes.length <= 4 ? 2 : 1
const list: number[] = []
for (let r = 0; r < reps; r++) prizes.forEach((_, i) => list.push(i))
return list
}, [prizes])
const count = segments.length
const slice = 360 / count
const restAngle = (seg: number) => 90 - (seg * slice + slice / 2)
const uid = useId().replace(/:/g, '')
const [internalOpen, setInternalOpen] = useState(true)
const isOpen = open ?? internalOpen
const [email, setEmail] = useState('')
const [fieldError, setFieldError] = useState('')
const [failed, setFailed] = useState('')
const [phase, setPhase] = useState<Phase>('idle')
const [prizeIndex, setPrizeIndex] = useState(0)
const [rotation, setRotation] = useState(() => restAngle(0))
const [copied, setCopied] = useState(false)
const inputRef = useRef<HTMLInputElement>(null)
const landedRef = useRef<HTMLHeadingElement>(null)
const closeRef = useRef<() => void>(() => {})
const forcedPrize = Math.min(1, prizes.length - 1)
const landed = state === 'success' || phase === 'landed'
const activePrize = state === 'success' ? forcedPrize : prizeIndex
const prize = prizes[activePrize] ?? prizes[0]
const shownRotation = state === 'success' ? restAngle(Math.max(0, segments.indexOf(forcedPrize))) : rotation
const disabled = state === 'disabled'
const busy = phase === 'pending' || phase === 'spinning'
const errorText = state === 'error' ? invalidEmail : fieldError
const rewardName = prize.wheelLabel ?? prize.value
const [before, after = ''] = landedTitle.split('{reward}')
const liveText = landed && state !== 'success' ? `${before}${rewardName}${after}.${prize.code ? ` ${codeLabel}: ${prize.code}` : ''}` : ''
const wheelAria = wheelAriaLabel.replace('{rewards}', prizes.map((p) => p.wheelLabel ?? p.value).join(', '))
const close = () => {
if (open === undefined) setInternalOpen(false)
onClose?.()
}
const reopen = () => {
if (open === undefined) setInternalOpen(true)
onOpen?.()
}
closeRef.current = close
useEffect(() => {
if (!isOpen || presentation !== 'drawer') return
inputRef.current?.focus({ preventScroll: true })
const onKey = (event: KeyboardEvent) => {
if (event.key === 'Escape') closeRef.current()
}
document.addEventListener('keydown', onKey)
return () => document.removeEventListener('keydown', onKey)
}, [isOpen, presentation])
useEffect(() => {
if (phase !== 'spinning') return
const timer = window.setTimeout(() => setPhase('landed'), 5600)
return () => window.clearTimeout(timer)
}, [phase])
useEffect(() => {
if (phase === 'landed') landedRef.current?.focus()
}, [phase])
const faceStyle = useMemo<React.CSSProperties>(() => {
const stops = segments.map((_, s) => `${sliceFill(s, count).bg} ${s * slice}deg ${(s + 1) * slice}deg`).join(', ')
return {
background: `radial-gradient(circle, transparent 55%, oklch(from var(--pw-shadow) l c h / .16) 100%), repeating-conic-gradient(from 0deg, oklch(from var(--band-ink) l c h / .7) 0deg .8deg, transparent .8deg ${slice}deg), conic-gradient(${stops})`,
}
}, [segments, count, slice])
async function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault()
if (busy || disabled || landed) return
const value = email.trim()
if (!EMAIL.test(value)) {
setFieldError(invalidEmail)
inputRef.current?.focus()
return
}
setFieldError('')
setFailed('')
setPhase('pending')
let chosen: void | number | undefined
try {
chosen = await onSubmit?.({ email: value })
} catch {
setFailed(submitError)
setPhase('idle')
return
}
const index = typeof chosen === 'number' && chosen >= 0 && chosen < prizes.length ? Math.floor(chosen) : Math.floor(Math.random() * prizes.length)
const options = segments.map((p, s) => (p === index ? s : -1)).filter((s) => s >= 0)
const seg = options[Math.floor(Math.random() * options.length)] ?? 0
const target = restAngle(seg) + (Math.random() - 0.5) * slice * 0.5
setPrizeIndex(index)
setCopied(false)
setRotation((current) => {
const base = current + 360 * 6
return base + ((((target - base) % 360) + 360) % 360)
})
const reduced = typeof window !== 'undefined' && window.matchMedia?.('(prefers-reduced-motion: reduce)').matches
setPhase(reduced ? 'landed' : 'spinning')
}
async function copyCode() {
if (!prize.code) return
try {
await navigator.clipboard.writeText(prize.code)
setCopied(true)
} catch {
setCopied(false)
}
}
const claim = () => onAction?.(prize, activePrize)
const cls = ['cf-prize-wheel-optin', className].filter(Boolean).join(' ')
if (!isOpen) {
return (
<div className={cls} data-presentation={presentation} data-closed='true'>
<style>{CSS}</style>
<button type='button' className='pw-reopen' onClick={reopen}>
<Gift size={20} strokeWidth={2.5} aria-hidden='true' />
{reopenLabel}
</button>
</div>
)
}
const at = highlight ? headline.indexOf(highlight) : -1
const titleNode =
at < 0 ? (
headline
) : (
<>
{headline.slice(0, at)}
<span className='pw-mark'>{highlight}</span>
{headline.slice(at + highlight.length)}
</>
)
return (
<div
className={cls}
data-presentation={presentation}
data-state={state}
onKeyDown={(event) => {
if (event.key === 'Escape' && presentation !== 'drawer') close()
}}
onClick={
presentation === 'drawer'
? (event) => {
if (event.target === event.currentTarget) close()
}
: undefined
}
>
<style>{CSS}</style>
<div
className='pw-panel'
role={presentation === 'drawer' ? 'dialog' : undefined}
aria-modal={presentation === 'drawer' ? true : undefined}
aria-labelledby={`${uid}-title`}
>
<button type='button' className='pw-close' aria-label={closeLabel} onClick={close}>
<X size={20} strokeWidth={2.5} aria-hidden='true' />
</button>
<div className='pw-head'>
<h2 id={`${uid}-title`} className='pw-title'>
{titleNode}
</h2>
{lead ? <p className='pw-lead'>{lead}</p> : null}
</div>
<div className='pw-wheel-area'>
<div className='pw-wheel' role='img' aria-label={wheelAria}>
<div
className='pw-disc'
data-instant={state === 'success' ? 'true' : undefined}
style={{ ...faceStyle, transform: `rotate(${shownRotation}deg)` }}
onTransitionEnd={(event) => {
if (event.target === event.currentTarget && event.propertyName === 'transform' && phase === 'spinning') setPhase('landed')
}}
>
{segments.map((p, s) => {
const fill = sliceFill(s, count)
return (
<span key={`slice-${s}`} className='pw-slice' style={{ transform: `rotate(${s * slice + slice / 2 - 90}deg)`, color: fill.ink }}>
<span className='pw-slice-text'>{prizes[p].wheelLabel ?? prizes[p].value}</span>
</span>
)
})}
{segments.map((_, s) => (
<i key={`peg-${s}`} className='pw-peg' style={{ transform: `rotate(${s * slice}deg)` }} />
))}
</div>
<span className='pw-hub'>
<Gift strokeWidth={2.5} aria-hidden='true' />
</span>
<svg className='pw-pointer' viewBox='0 0 72 44' aria-hidden='true'>
<path className='pw-pointer-body' d='M2 22 L40 6.5 C44 4.6 48.4 3 53 3 A19 19 0 0 1 53 41 C48.4 41 44 39.4 40 37.5 Z' />
<path className='pw-pointer-shine' d='M11 19 L40.5 9 C44 7.6 48 6.6 52 6.6' />
<circle className='pw-pointer-pin' cx='53' cy='22' r='7' />
</svg>
</div>
{wheelNote ? (
<p className='pw-note'>
<ShieldCheck className='pw-inline-icon' strokeWidth={2.5} aria-hidden='true' />
{wheelNote}
</p>
) : null}
</div>
<ul className='pw-prizes' aria-label={prizesLabel}>
{prizes.map((p, i) => {
const isWin = landed && i === activePrize
return (
<li key={`prize-${i}`} className='pw-prize' data-landed={isWin ? 'true' : undefined} style={{ '--i': i } as React.CSSProperties}>
{isWin ? (
<span className='pw-flag'>
<Check size={16} strokeWidth={3} aria-hidden='true' />
{landedFlag}
</span>
) : null}
<span className='pw-prize-value'>{p.value}</span>
{p.image ? <img className='pw-prize-img' src={p.image} alt={p.imageAlt ?? ''} width={52} height={52} loading='lazy' /> : null}
<span className='pw-prize-label'>{p.label}</span>
</li>
)
})}
</ul>
<div className='pw-action'>
{landed ? (
<div className='pw-landed'>
<h3 ref={landedRef} tabIndex={-1} className='pw-landed-title'>
{before}
<span className='pw-mark'>{rewardName}</span>
{after}
</h3>
{prize.code ? (
<>
<p className='pw-code-label' id={`${uid}-code`}>
{codeLabel}
</p>
<div className='pw-code-row'>
<output className='pw-code' aria-labelledby={`${uid}-code`}>
{prize.code}
</output>
<button type='button' className='pw-copy' onClick={copyCode}>
{copied ? <Check size={18} strokeWidth={2.5} aria-hidden='true' /> : <Copy size={18} strokeWidth={2.5} aria-hidden='true' />}
{copied ? copiedLabel : copyLabel}
</button>
</div>
</>
) : null}
{href ? (
<a className='pw-btn' href={href} onClick={claim}>
{claimLabel}
</a>
) : (
<button type='button' className='pw-btn' onClick={claim}>
{claimLabel}
</button>
)}
{prize.code && codeNote ? <p className='pw-small'>{codeNote}</p> : null}
</div>
) : (
<form className='pw-form' noValidate onSubmit={handleSubmit} aria-busy={busy ? true : undefined}>
<label className='pw-label' htmlFor={`${uid}-email`}>
{emailLabel}
</label>
<input
ref={inputRef}
id={`${uid}-email`}
className='pw-field'
type='email'
name='email'
autoComplete='email'
inputMode='email'
placeholder={emailPlaceholder}
value={email}
onChange={(event) => {
setEmail(event.target.value)
if (fieldError) setFieldError('')
}}
disabled={disabled}
readOnly={busy}
required
aria-invalid={errorText ? true : undefined}
aria-describedby={errorText ? `${uid}-error` : undefined}
/>
{errorText ? (
<p className='pw-error' id={`${uid}-error`} role='alert'>
<span className='pw-badge' aria-hidden='true'>
<X size={12} strokeWidth={3} />
</span>
{errorText}
</p>
) : null}
<button type='submit' className='pw-btn pw-spin' disabled={disabled} aria-disabled={busy ? true : undefined}>
{phase === 'pending' ? <Loader2 className='pw-loader' size={20} strokeWidth={2.5} aria-hidden='true' /> : null}
{busy ? spinningLabel : spinLabel}
</button>
{failed ? (
<p className='pw-error' role='alert'>
<span className='pw-badge' aria-hidden='true'>
<X size={12} strokeWidth={3} />
</span>
{failed}
</p>
) : null}
{reassurance ? (
<p className='pw-small'>
<Lock className='pw-inline-icon' strokeWidth={2.5} aria-hidden='true' />
{reassurance}
</p>
) : null}
</form>
)}
</div>
{declineLabel ? (
<div className='pw-decline-row'>
<button type='button' className='pw-decline' onClick={close}>
{declineLabel}
</button>
</div>
) : null}
<p className='pw-sr' aria-live='polite'>
{liveText}
</p>
</div>
</div>
)
}
export default PrizeWheelOptin
// Slices alternate a pale action tint (ink text) with the band (band-ink text); an odd count closes on a pale accent tint so no two neighbours match.
// Tints blend in oklab: the card carries the theme's hue on dark themes, and an oklch mix would swing gold toward purple or green.
function sliceFill(index: number, count: number) {
if (count % 2 === 1 && index === count - 1) return { bg: 'color-mix(in oklab, var(--accent-fill, var(--accent)) 20%, var(--card))', ink: 'var(--ink)' }
return index % 2 === 0
? { bg: 'color-mix(in oklab, var(--cta) 16%, var(--card))', ink: 'var(--ink)' }
: { bg: 'var(--band)', ink: 'var(--band-ink)' }
}
const CSS = `
.cf-prize-wheel-optin{--pw-shadow:var(--shadow, oklch(0.22 0.03 260));--pw-ease:cubic-bezier(.2,.7,.2,1);container-type:inline-size;width:100%;font-family:var(--font-body);color:var(--ink);text-align:left}
.cf-prize-wheel-optin *,.cf-prize-wheel-optin *::before,.cf-prize-wheel-optin *::after{box-sizing:border-box}
.cf-prize-wheel-optin .pw-panel{position:relative;max-width:1080px;margin-inline:auto;display:grid;grid-template-columns:minmax(0,1fr);grid-template-areas:'head' 'wheel' 'action' 'prizes' 'decline';gap:24px;padding:clamp(20px,4cqi,40px);background:var(--card);color:var(--ink);border:1px solid var(--card-border, oklch(from var(--ink) l c h / .12));border-radius:var(--card-radius, var(--radius, 14px));box-shadow:var(--card-shadow, var(--shadow-lg, 0 2px 4px oklch(0.22 0.03 260 / .22), 0 12px 24px -8px oklch(0.22 0.03 260 / .32)))}
.cf-prize-wheel-optin .pw-head{grid-area:head;padding-inline-end:44px}
.cf-prize-wheel-optin .pw-title{margin:0;font-family:var(--font-display);font-weight:var(--display-weight,800);letter-spacing:var(--display-tracking,-.025em);text-transform:var(--display-case,none);font-size:clamp(2rem,4.2cqi,3rem);line-height:1.06;color:var(--ink);text-wrap:balance}
.cf-prize-wheel-optin .pw-mark{color:var(--field-ink);background:linear-gradient(transparent 6%, color-mix(in oklch, var(--marker, #fae37c) 84%, transparent) 6%, color-mix(in oklch, var(--marker, #fae37c) 84%, transparent) 97%, transparent 97%);padding-inline:.12em;margin-inline:-.04em;border-radius:.12em .22em .14em .26em;-webkit-box-decoration-break:clone;box-decoration-break:clone}
.cf-prize-wheel-optin .pw-lead{margin:16px 0 0;max-width:52ch;font-size:clamp(1.125rem,1.9cqi,1.375rem);line-height:1.4;font-weight:500;color:var(--muted);text-wrap:pretty}
.cf-prize-wheel-optin .pw-wheel-area{grid-area:wheel;display:grid;justify-items:center;gap:16px}
.cf-prize-wheel-optin .pw-wheel{position:relative;width:min(92%,340px);aspect-ratio:1;container-type:inline-size;padding:4%;border-radius:50%;background:linear-gradient(160deg,oklch(from var(--band) calc(l + .1) c h),oklch(from var(--band) calc(l - .04) c h));box-shadow:inset 0 0 0 2px oklch(from var(--accent-fill, var(--accent)) l c h / .55),inset 0 3px 0 oklch(from var(--band-ink) l c h / .18),inset 0 -3px 0 oklch(from var(--band) calc(l - .1) c h);filter:drop-shadow(0 2px 3px oklch(from var(--pw-shadow) l c h / .3)) drop-shadow(0 14px 14px oklch(from var(--pw-shadow) l c h / .18))}
.cf-prize-wheel-optin .pw-disc{position:relative;width:100%;height:100%;border-radius:50%;overflow:hidden;transition:transform 4.8s cubic-bezier(.14,.74,.1,1);will-change:transform;box-shadow:0 0 0 2px oklch(from var(--band) calc(l - .08) c h)}
.cf-prize-wheel-optin .pw-disc[data-instant='true']{transition:none}
.cf-prize-wheel-optin .pw-slice{position:absolute;left:50%;top:50%;width:50%;height:0;transform-origin:0 0;display:flex;align-items:center;justify-content:flex-end;padding-right:9cqi;pointer-events:none}
.cf-prize-wheel-optin .pw-slice-text{width:25cqi;font-family:var(--font-display);font-weight:800;font-size:clamp(.875rem,3.7cqi,1.0625rem);line-height:1.08;letter-spacing:-.01em;text-align:center;text-wrap:balance;overflow-wrap:break-word}
.cf-prize-wheel-optin .pw-peg{position:absolute;inset:0;pointer-events:none}
.cf-prize-wheel-optin .pw-peg::before{content:'';position:absolute;left:50%;top:1.4%;width:3.4%;aspect-ratio:1;translate:-50% 0;border-radius:50%;background:var(--band-ink);box-shadow:0 1px 2px oklch(from var(--pw-shadow) l c h / .45)}
.cf-prize-wheel-optin .pw-hub{position:absolute;left:50%;top:50%;z-index:2;width:20%;aspect-ratio:1;translate:-50% -50%;display:grid;place-items:center;border-radius:50%;border:clamp(4px,1.8cqi,8px) solid var(--band-ink);background:linear-gradient(oklch(from var(--cta) calc(l + .05) c h),oklch(from var(--cta-2) calc(l - .02) c h));color:var(--cta-ink);box-shadow:inset 0 1px 0 oklch(from var(--cta) calc(l + .16) c h / .7),0 1px 2px oklch(from var(--pw-shadow) l c h / .35),0 6px 10px -3px oklch(from var(--pw-shadow) l c h / .35)}
.cf-prize-wheel-optin .pw-hub svg{width:46%;height:46%}
.cf-prize-wheel-optin .pw-pointer{position:absolute;right:-3%;top:50%;z-index:3;width:14%;height:auto;aspect-ratio:72/44;translate:0 -50%;overflow:visible;filter:drop-shadow(0 2px 2px oklch(from var(--pw-shadow) l c h / .4))}
.cf-prize-wheel-optin .pw-pointer-body{fill:var(--accent-fill, var(--accent));stroke:oklch(from var(--accent-fill, var(--accent)) calc(l - .14) c h);stroke-width:1.5}
.cf-prize-wheel-optin .pw-pointer-shine{fill:none;stroke:oklch(from var(--accent-fill, var(--accent)) calc(l + .16) c h / .7);stroke-width:2;stroke-linecap:round}
.cf-prize-wheel-optin .pw-pointer-pin{fill:var(--accent-fill-ink, var(--card));stroke:oklch(from var(--accent-fill, var(--accent)) calc(l - .14) c h);stroke-width:1.5}
.cf-prize-wheel-optin .pw-note{margin:0;max-width:34ch;font-size:15px;line-height:1.4;font-weight:600;color:var(--muted);text-align:center;text-wrap:pretty}
.cf-prize-wheel-optin .pw-inline-icon{display:inline-block;width:1.1em;height:1.1em;vertical-align:-.18em;margin-inline-end:.4em}
.cf-prize-wheel-optin .pw-note .pw-inline-icon{color:var(--accent)}
.cf-prize-wheel-optin .pw-prizes{grid-area:prizes;list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px 12px}
.cf-prize-wheel-optin .pw-prize:last-child:nth-child(odd){grid-column:1 / -1}
.cf-prize-wheel-optin .pw-prize{position:relative;display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;column-gap:12px;padding:16px;border-radius:12px;background:color-mix(in oklch, var(--ink) 4%, var(--card));border:1px solid transparent;transition:background .16s ease,border-color .16s ease,box-shadow .16s ease,translate .16s ease;animation:cfpw-rise .45s var(--pw-ease) both;animation-delay:calc(min(var(--i, 0), 4) * .07s)}
.cf-prize-wheel-optin .pw-prize-value{grid-column:1;grid-row:1;align-self:center;font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.75rem,3.6cqi,2.5rem);line-height:1;letter-spacing:-.03em;font-variant-numeric:tabular-nums;color:var(--ink);overflow-wrap:anywhere}
.cf-prize-wheel-optin .pw-prize-img{grid-column:2;grid-row:1;width:clamp(44px,5cqi,52px);height:auto;aspect-ratio:1;border-radius:8px;object-fit:cover;display:block;filter:drop-shadow(0 1px 2px oklch(from var(--pw-shadow) l c h / .28)) drop-shadow(0 4px 6px oklch(from var(--pw-shadow) l c h / .16))}
.cf-prize-wheel-optin .pw-prize-label{grid-column:1 / -1;margin-top:10px;font-size:15px;line-height:1.35;font-weight:600;color:var(--muted);text-wrap:pretty}
.cf-prize-wheel-optin .pw-prize[data-landed='true']{background:color-mix(in oklab, var(--accent) 12%, var(--card));border-color:oklch(from var(--accent) l c h / .5);box-shadow:var(--shadow-lg, 0 2px 4px oklch(0.22 0.03 260 / .22), 0 12px 24px -8px oklch(0.22 0.03 260 / .32));translate:0 -2px}
.cf-prize-wheel-optin .pw-prize[data-landed='true'] .pw-prize-label{color:var(--ink)}
.cf-prize-wheel-optin .pw-flag{position:absolute;left:12px;top:-14px;display:inline-flex;align-items:center;gap:6px;min-height:28px;padding:4px 12px;border-radius:999px;background:var(--accent-fill, var(--accent));color:var(--accent-fill-ink, var(--card));font-size:14px;font-weight:800;line-height:1.2;white-space:nowrap;animation:cfpw-pop .3s var(--pw-ease) both}
.cf-prize-wheel-optin .pw-action{grid-area:action;padding:clamp(20px,3cqi,28px);border-radius:12px;background:var(--band);color:var(--band-ink)}
.cf-prize-wheel-optin .pw-form{margin:0}
.cf-prize-wheel-optin .pw-label{display:block;margin-bottom:8px;font-size:17px;font-weight:700;line-height:1.3;color:var(--band-ink)}
.cf-prize-wheel-optin .pw-field{display:block;width:100%;height:56px;padding:0 16px;font-family:var(--font-body);font-size:17px;color:var(--field-ink);background:var(--field);border:1px solid var(--field-border, color-mix(in oklch, var(--ink) 22%, transparent));border-radius:var(--field-radius, var(--radius, 12px));outline:none;transition:border-color .16s ease,box-shadow .16s ease}
.cf-prize-wheel-optin .pw-field::placeholder{color:color-mix(in oklch, var(--field-ink) 65%, var(--field));opacity:1}
.cf-prize-wheel-optin .pw-field:focus{border-color:var(--field-focus, var(--accent));box-shadow:0 0 0 3px oklch(from var(--field-focus, var(--accent)) l c h / .35),0 0 0 5px oklch(from var(--band-ink) l c h / .7)}
.cf-prize-wheel-optin .pw-field[aria-invalid='true']{border-color:var(--danger);box-shadow:inset 0 0 0 1px var(--danger)}
.cf-prize-wheel-optin .pw-field[aria-invalid='true']:focus{box-shadow:inset 0 0 0 1px var(--danger),0 0 0 3px oklch(from var(--band-ink) l c h / .7)}
.cf-prize-wheel-optin .pw-field:disabled{cursor:not-allowed;background:color-mix(in oklch, var(--field-ink) 8%, var(--field))}
.cf-prize-wheel-optin .pw-field[readonly]{cursor:progress}
.cf-prize-wheel-optin .pw-error{margin:10px 0 0;font-size:15px;line-height:1.4;font-weight:600;color:var(--band-ink);text-wrap:pretty}
.cf-prize-wheel-optin .pw-badge{display:inline-grid;place-items:center;width:20px;height:20px;margin-inline-end:.45em;vertical-align:-.3em;border-radius:50%;background:var(--danger);color:oklch(from var(--danger) 1 0 h);box-shadow:0 0 0 2px oklch(from var(--band-ink) l c h / .9)}
.cf-prize-wheel-optin .pw-btn,.cf-prize-wheel-optin .pw-reopen{display:flex;align-items:center;justify-content:center;gap:10px;border:0;border-radius:var(--button-radius, var(--radius, 12px));font-family:var(--button-font, var(--font-display));font-weight:var(--button-weight,800);line-height:1.15;text-transform:var(--button-case,none);text-align:center;text-decoration:none;text-wrap:balance;color:var(--button-ink, var(--cta-ink));text-shadow:var(--button-text-shadow,none);background:linear-gradient(oklch(from var(--button-bg, var(--cta)) calc(l + .04) c h),oklch(from var(--button-bg-2, var(--cta-2)) calc(l - .02) c h));box-shadow:var(--button-shadow, inset 0 1px 0 oklch(from var(--button-bg, var(--cta)) calc(l + .14) c h / .7), inset 0 -3px 0 oklch(from var(--button-bg, var(--cta)) calc(l - .16) c h), 0 1px 2px oklch(from var(--pw-shadow) l c h / .35), 0 8px 16px -6px oklch(from var(--pw-shadow) l c h / .5));cursor:pointer;transition:background .16s ease,box-shadow .16s ease,transform .16s ease}
.cf-prize-wheel-optin .pw-btn{width:100%;min-height:56px;margin-top:14px;padding:12px 16px;font-size:clamp(1.125rem,2cqi,1.3125rem)}
.cf-prize-wheel-optin .pw-btn:hover:not(:disabled):not([aria-disabled='true']),.cf-prize-wheel-optin .pw-reopen:hover,.cf-prize-wheel-optin[data-state='hover'] .pw-spin:not(:disabled){background:linear-gradient(oklch(from var(--button-bg, var(--cta)) calc(l - .01) c h),oklch(from var(--button-bg-2, var(--cta-2)) calc(l - .07) c h));box-shadow:inset 0 1px 0 oklch(from var(--button-bg, var(--cta)) calc(l + .12) c h / .6),inset 0 -3px 0 oklch(from var(--button-bg, var(--cta)) calc(l - .18) c h),0 1px 2px oklch(from var(--pw-shadow) l c h / .4),0 10px 18px -6px oklch(from var(--pw-shadow) l c h / .55);transform:translateY(-1px)}
.cf-prize-wheel-optin .pw-btn:active:not(:disabled):not([aria-disabled='true']),.cf-prize-wheel-optin .pw-reopen:active,.cf-prize-wheel-optin[data-state='active'] .pw-spin:not(:disabled){transform:translateY(1px);box-shadow:inset 0 2px 4px oklch(from var(--button-bg-2, var(--cta-2)) calc(l - .2) c h / .45),inset 0 -2px 0 oklch(from var(--button-bg, var(--cta)) calc(l - .16) c h),0 1px 1px oklch(from var(--pw-shadow) l c h / .3)}
.cf-prize-wheel-optin .pw-btn:focus-visible{outline:3px solid var(--band-ink);outline-offset:3px}
.cf-prize-wheel-optin .pw-btn:disabled{cursor:not-allowed;transform:none;background:var(--secondary);color:var(--secondary-ink);text-shadow:none;box-shadow:var(--shadow-sm, 0 1px 2px oklch(0.22 0.03 260 / .2))}
.cf-prize-wheel-optin .pw-btn[aria-disabled='true']{cursor:progress}
.cf-prize-wheel-optin .pw-loader{flex:none;animation:cfpw-turn .8s linear infinite}
.cf-prize-wheel-optin .pw-small{margin:12px 0 0;font-size:15px;line-height:1.4;font-weight:500;text-align:center;color:color-mix(in oklch, var(--band-ink) 86%, var(--band));text-wrap:pretty}
.cf-prize-wheel-optin .pw-landed-title{margin:0;font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.3125rem,2.6cqi,1.625rem);line-height:1.2;letter-spacing:-.01em;color:var(--band-ink);text-wrap:balance;outline:none}
.cf-prize-wheel-optin .pw-code-label{margin:18px 0 8px;font-size:14px;font-weight:800;line-height:1.2;letter-spacing:.08em;text-transform:uppercase;color:color-mix(in oklch, var(--band-ink) 86%, var(--band))}
.cf-prize-wheel-optin .pw-code-row{display:flex;flex-wrap:wrap;gap:8px}
.cf-prize-wheel-optin .pw-code{flex:1 1 180px;display:flex;align-items:center;min-height:52px;padding:8px 16px;border-radius:10px;background:var(--card);color:var(--ink);border:1px solid oklch(from var(--band-ink) l c h / .3);font-family:var(--font-display);font-weight:800;font-size:clamp(1.125rem,2.2cqi,1.375rem);letter-spacing:.1em;font-variant-numeric:tabular-nums;user-select:all;overflow-wrap:anywhere;animation:cfpw-pop .3s var(--pw-ease) both}
.cf-prize-wheel-optin .pw-copy{flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:52px;padding:0 18px;border:1px solid var(--button-2-border, transparent);border-radius:var(--button-radius, var(--radius, 12px));background:var(--button-2-bg, var(--secondary));color:var(--button-2-ink, var(--secondary-ink));box-shadow:var(--button-2-shadow, var(--shadow-sm));font-family:var(--button-font, var(--font-display));font-weight:var(--button-weight,800);font-size:16px;cursor:pointer;transition:background .16s ease,transform .16s ease}
.cf-prize-wheel-optin .pw-copy:hover{background:oklch(from var(--button-2-bg, var(--secondary)) calc(l - .04) c h)}
.cf-prize-wheel-optin .pw-copy:active{transform:translateY(1px)}
.cf-prize-wheel-optin .pw-copy:focus-visible{outline:3px solid var(--band-ink);outline-offset:3px}
.cf-prize-wheel-optin .pw-landed .pw-btn{margin-top:16px}
.cf-prize-wheel-optin .pw-decline-row{grid-area:decline;text-align:center}
.cf-prize-wheel-optin .pw-decline{min-height:44px;padding:10px 8px;border:0;background:none;font-family:var(--font-body);font-size:15px;font-weight:500;color:var(--muted);text-decoration:underline;text-decoration-color:oklch(from var(--muted) l c h / .5);text-underline-offset:.18em;cursor:pointer}
.cf-prize-wheel-optin .pw-decline:hover{color:var(--ink);text-decoration-color:currentColor}
.cf-prize-wheel-optin .pw-close{position:absolute;top:12px;right:12px;z-index:4;display:grid;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:999px;background:color-mix(in oklch, var(--ink) 6%, var(--card));color:var(--ink);cursor:pointer;transition:background .16s ease,transform .16s ease}
.cf-prize-wheel-optin .pw-close:hover{background:color-mix(in oklch, var(--ink) 12%, var(--card))}
.cf-prize-wheel-optin .pw-close:active{transform:scale(.96)}
.cf-prize-wheel-optin .pw-close:focus-visible,.cf-prize-wheel-optin .pw-decline:focus-visible,.cf-prize-wheel-optin .pw-reopen:focus-visible{outline:3px solid var(--field-focus, var(--accent));outline-offset:2px}
.cf-prize-wheel-optin .pw-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
.cf-prize-wheel-optin[data-closed='true']{text-align:center}
.cf-prize-wheel-optin .pw-reopen{display:inline-flex;min-height:56px;padding:0 24px;border-radius:999px;font-size:1.125rem;animation:cfpw-pop .3s var(--pw-ease) both}
.cf-prize-wheel-optin[data-presentation='drawer'][data-closed='true'] .pw-reopen{position:fixed;left:0;top:50%;z-index:1000;translate:0 -50%;border-radius:0 999px 999px 0}
.cf-prize-wheel-optin[data-presentation='drawer']:not([data-closed]){position:fixed;inset:0;z-index:1000;display:flex;justify-content:flex-start;background:oklch(from var(--band) l c h / .6)}
.cf-prize-wheel-optin[data-presentation='drawer']:not([data-closed]) .pw-panel{width:min(100%,1040px);max-width:none;height:100dvh;margin:0;overflow-y:auto;overscroll-behavior:contain;align-content:start;border-width:0 1px 0 0;border-radius:0 var(--card-radius, var(--radius, 14px)) var(--card-radius, var(--radius, 14px)) 0;animation:cfpw-slide .45s var(--pw-ease) both}
@container (min-width: 860px){
.cf-prize-wheel-optin .pw-panel{grid-template-columns:minmax(0,.92fr) minmax(0,1.08fr);grid-template-areas:'wheel head' 'wheel prizes' 'action action' 'decline decline';grid-template-rows:auto 1fr auto auto;column-gap:clamp(32px,5cqi,64px);row-gap:24px;align-items:start}
.cf-prize-wheel-optin .pw-wheel{width:min(100%,460px)}
.cf-prize-wheel-optin .pw-form{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:12px}
.cf-prize-wheel-optin .pw-label{grid-column:1 / -1}
.cf-prize-wheel-optin .pw-field{grid-column:1;grid-row:2}
.cf-prize-wheel-optin .pw-spin{grid-column:2;grid-row:2;width:auto;min-width:300px;margin-top:0;padding-inline:28px;white-space:nowrap}
.cf-prize-wheel-optin .pw-form .pw-error,.cf-prize-wheel-optin .pw-form .pw-small{grid-column:1 / -1;text-align:left}
.cf-prize-wheel-optin .pw-landed{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:16px;align-items:end}
.cf-prize-wheel-optin .pw-landed > *{grid-column:1 / -1}
.cf-prize-wheel-optin .pw-landed .pw-code-row{grid-column:1}
.cf-prize-wheel-optin .pw-landed .pw-btn{grid-column:2;width:auto;min-width:280px;margin-top:0;padding-inline:28px;white-space:nowrap}
.cf-prize-wheel-optin .pw-landed .pw-small{text-align:left}
}
@keyframes cfpw-rise{from{opacity:.82;transform:translateY(8px)}}
@keyframes cfpw-pop{from{transform:scale(.9)}}
@keyframes cfpw-slide{from{opacity:.82;transform:translateX(-24px)}}
@keyframes cfpw-turn{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion: reduce){
.cf-prize-wheel-optin .pw-disc{transition:none}
.cf-prize-wheel-optin .pw-prize,.cf-prize-wheel-optin .pw-flag,.cf-prize-wheel-optin .pw-code,.cf-prize-wheel-optin .pw-reopen,.cf-prize-wheel-optin .pw-panel,.cf-prize-wheel-optin .pw-loader{animation:none !important}
.cf-prize-wheel-optin .pw-btn,.cf-prize-wheel-optin .pw-reopen,.cf-prize-wheel-optin .pw-prize,.cf-prize-wheel-optin .pw-close,.cf-prize-wheel-optin .pw-copy,.cf-prize-wheel-optin .pw-field{transition:none}
}
`
pieces/attention/prize-wheel-optin/specimen.tsx 31 lines
// Specimen: the prize-wheel opt-in where every slice is a real reward for The Funnel Starter Kit.
import defaults from '../../studio-defaults.json'
import { slot } from '../../slots'
import { PrizeWheelOptin, type PrizeWheelOptinProps } from '../prize-wheel-optin'
export const states = ['default', 'hover', 'active', 'disabled', 'error', 'success']
export default function PrizeWheelOptinSpecimen({ state }: { state?: PrizeWheelOptinProps['state'] }) {
const sample = defaults.sample
const [guide, workbook, checklist] = sample.items
return (
<PrizeWheelOptin
state={state}
headline='Spin once. Every slice is yours to keep.'
highlight='yours to keep'
lead={`Enter your email, spin once, and we’ll send the reward you land on for ${sample.name}.`}
prizes={[
{ value: '15%', label: `off ${sample.name}`, wheelLabel: '15% off', code: 'SPIN15' },
{ value: guide.value, label: `${guide.name}, free with your kit`, wheelLabel: 'Free guide', code: 'GUIDE49', image: slot('item-1', guide.image), imageAlt: guide.imageAlt },
{ value: workbook.value, label: `${workbook.name}, free with your kit`, wheelLabel: 'Free workbook', code: 'WORKBOOK29', image: slot('item-2', workbook.image), imageAlt: workbook.imageAlt },
{ value: checklist.value, label: `${checklist.name}, free with your kit`, wheelLabel: 'Free checklist', code: 'CHECK19', image: slot('item-3', checklist.image), imageAlt: checklist.imageAlt },
]}
wheelNote='No empty slices. You land on one of these four rewards.'
spinLabel='Spin & send my reward'
reassurance='Just your email. No card, no catch.'
codeNote={`Paste it at checkout for ${sample.name}.`}
claimLabel='Send me to checkout'
declineLabel='No thanks, I’ll skip my reward'
/>
)
}
| Name | Type | Details |
|---|---|---|
headline OptionalPrizeWheelOptin |
string |
|
highlight OptionalPrizeWheelOptin |
string |
|
lead OptionalPrizeWheelOptin |
string |
|
prizes OptionalPrizeWheelOptin |
PrizeWheelPrize[] |
|
prizesLabel OptionalPrizeWheelOptin |
string |
|
wheelNote OptionalPrizeWheelOptin |
string |
|
wheelAriaLabel OptionalPrizeWheelOptin |
string |
|
emailLabel OptionalPrizeWheelOptin |
string |
|
emailPlaceholder OptionalPrizeWheelOptin |
string |
|
spinLabel OptionalPrizeWheelOptin |
string |
|
spinningLabel OptionalPrizeWheelOptin |
string |
|
reassurance OptionalPrizeWheelOptin |
string |
|
invalidEmail OptionalPrizeWheelOptin |
string |
|
submitError OptionalPrizeWheelOptin |
string |
|
landedTitle OptionalPrizeWheelOptin |
string |
|
landedFlag OptionalPrizeWheelOptin |
string |
|
codeLabel OptionalPrizeWheelOptin |
string |
|
copyLabel OptionalPrizeWheelOptin |
string |
|
copiedLabel OptionalPrizeWheelOptin |
string |
|
codeNote OptionalPrizeWheelOptin |
string |
|
claimLabel OptionalPrizeWheelOptin |
string |
|
declineLabel OptionalPrizeWheelOptin |
string |
|
closeLabel OptionalPrizeWheelOptin |
string |
|
reopenLabel OptionalPrizeWheelOptin |
string |
|
presentation OptionalPrizeWheelOptin |
'inline' | 'drawer' |
|
open OptionalPrizeWheelOptin |
boolean |
|
onSubmit OptionalPrizeWheelOptin |
(values: { email: string }) => void | number | Promise<void | number> |
|
onAction OptionalPrizeWheelOptin |
(prize: PrizeWheelPrize, index: number) => void |
|
href OptionalPrizeWheelOptin |
string |
|
onClose OptionalPrizeWheelOptin |
() => void |
|
onOpen OptionalPrizeWheelOptin |
() => void |
|
state OptionalPrizeWheelOptin |
'default' | 'hover' | 'active' | 'disabled' | 'error' | 'success' |
|
className OptionalPrizeWheelOptin |
string |
Theme roles it reads
Set by the theme bar, a preset or your brand. Colours come from the base tokens (--surface, --ink, --cta…) every piece uses.
--button-bg--button-bg-2--button-case--button-font--button-ink--button-radius--button-shadow--button-text-shadow--button-weight- Main CTA button: background, ink, font, weight, case, radius and shadow.
--button-2-bg--button-2-border--button-2-ink--button-2-shadow- Secondary button.
--card-border--card-radius--card-shadow- Cards and panels: radius, border and shadow.
--display-case--display-tracking--display-weight- Headlines: weight, letter case and tracking.
--field--field-border--field-focus--field-ink--field-radius- Form inputs: background, ink, border, radius and focus colour.
--marker- The highlighter colour behind key phrases.
Image slots
Filled from the brand’s images; the specimen ships its own defaults.
item-1- One image per offer item (item-1, item-2…), shown in stacks and lists.
item-2- One image per offer item (item-1, item-2…), shown in stacks and lists.
item-3- One image per offer item (item-1, item-2…), shown in stacks and lists.
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB