Tour (motion)
The styled tour card animated with motion — a spring spotlight that glides between targets.
Loopworknight-drive.lwp
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
Drums
Beat A
Beat B
Bass
Sub line
Keys
Rhodes
Vox
Hook (dry)
Beat A
16 steps · drumsKick
Snare
Hat
Clap
Mixer
4 channelsDrums
80%
Bass
35%
Keys
60%
Vox
50%
import { createTour, Tour } from '@awesome-tour/react';import { LoopworkApp, parts } from '@loopwork';import { useState } from 'react';import { TourMotionPopover } from '@/components/awesome-tour/tour-motion';import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue,} from '@/components/ui/select';import { DemoFrame, StartButton } from './ui';
const $ = parts('in-motion');
const tour = createTour({ id: 'docs-motion', steps: [ { id: 'play', target: $('play'), title: 'Press play', description: 'Then go next and watch the spotlight ride the playhead.', }, { id: 'playhead', target: $('playhead'), title: 'Springs follow', description: 'The cutout chases a moving target with a spring instead of jumping.', }, { id: 'clips', target: [$('clip-c1'), $('clip-c3')], title: 'Shapes morph', description: 'Between steps the cutout morphs from one shape to the next.', }, { id: 'reduced', target: $('mixer'), side: 'left', title: 'Reduced motion', description: 'With prefers-reduced-motion, every transition is instant.', }, ],});
const presets = ['slide', 'scale', 'fade', 'pop'] as const;type Preset = (typeof presets)[number];
export function MotionDemo() { const [preset, setPreset] = useState<Preset>('slide'); return ( <Tour.Root tour={tour}> <DemoFrame title="@awesome-tour/motion" actions={ <> <Select value={preset} onValueChange={(v) => setPreset(v as Preset)}> <SelectTrigger size="sm" aria-label="Animation preset" className="w-28"> <SelectValue /> </SelectTrigger> <SelectContent> {presets.map((p) => ( <SelectItem key={p} value={p}> {p} </SelectItem> ))} </SelectContent> </Select> <StartButton /> </> } > <LoopworkApp scope="in-motion" /> </DemoFrame> <TourMotionPopover preset={preset} /> </Tour.Root> );}Installation
pnpm dlx shadcn@latest add @awesome-tour/tour-motionnpx shadcn@latest add @awesome-tour/tour-motionInstalls tour, @awesome-tour/motion and motion.
Usage
import { TourMotionPopover } from '@/components/awesome-tour/tour-motion';
<Tour.Root tour={tour}> <TourMotionPopover preset="slide" backdrop="overlay" /></Tour.Root>| Prop | Type | Default |
|---|---|---|
backdrop |
'overlay' | 'spotlight' | 'none' |
'overlay' |
preset |
'slide' | 'scale' | 'fade' | 'pop' |
'slide' |
animateStepChange |
boolean |
true |
progress · dots · skip · size |
as in TourPopover |
Parts: TourMotionOverlay, TourMotionSpotlight, TourMotionCard. Reduced-motion users get instant
transitions.
Source
'use client';
import { MotionContent, type MotionContentProps, MotionOverlay, type MotionOverlayProps, MotionSpotlight, type MotionSpotlightProps,} from '@awesome-tour/motion';import { Tour } from '@awesome-tour/react';import { TourCardContents, type TourCardContentsProps, TourCardFrame, type TourCardProps, tourCardVariants,} from '@/components/awesome-tour/tour';import { cn } from '@/lib/utils';
/** Overlay whose cutout glides between targets with a spring. */function TourMotionOverlay({ padding = 6, radius = 10, className, ...props }: MotionOverlayProps) { return ( <MotionOverlay data-slot="tour-overlay" padding={padding} radius={radius} className={cn('z-50', className)} {...props} /> );}
/** A ring that glides between targets. */function TourMotionSpotlight({ padding = 6, className, ...props }: MotionSpotlightProps) { return ( <MotionSpotlight data-slot="tour-spotlight" padding={padding} className={cn( 'z-50 rounded-lg ring-2 ring-primary ring-offset-2 ring-offset-background', 'shadow-[0_0_0_6px_color-mix(in_oklab,var(--color-primary)_20%,transparent)]', className, )} {...props} /> );}
export interface TourMotionCardProps extends MotionContentProps { size?: TourCardProps['size']; arrow?: boolean;}
/** `TourCard` animated by motion: spring enter/exit and a cross-fade between steps. */function TourMotionCard({ size, arrow = true, preset = 'slide', animateStepChange = true, sideOffset = 14, collisionPadding = 16, className, children, ...props}: TourMotionCardProps) { return ( <MotionContent data-slot="tour-card" preset={preset} animateStepChange={animateStepChange} sideOffset={sideOffset} collisionPadding={collisionPadding} className={cn(tourCardVariants({ size, animated: false }), className)} {...props} > <TourCardFrame size={size} arrow={arrow}> {children} </TourCardFrame> </MotionContent> );}
export interface TourMotionPopoverProps extends Omit<TourMotionCardProps, 'children'>, TourCardContentsProps { /** `overlay` dims the page, `spotlight` only rings the target, `none` renders neither. */ backdrop?: 'overlay' | 'spotlight' | 'none';}
/** The complete animated tour UI. */function TourMotionPopover({ backdrop = 'overlay', progress, dots, skip, children, ...props}: TourMotionPopoverProps) { return ( <Tour.Portal> {backdrop === 'overlay' && <TourMotionOverlay />} {backdrop === 'spotlight' && <TourMotionSpotlight />} <TourMotionCard {...props}> <TourCardContents progress={progress} dots={dots} skip={skip}> {children} </TourCardContents> </TourMotionCard> </Tour.Portal> );}
export { TourMotionCard, TourMotionOverlay, TourMotionPopover, TourMotionSpotlight };