JGuang

Scroll Based Velocity

Scroll Based Velocity · Magic UI

Preview
npx shadcn@latest add https://jiguang132.com/r/magic-ui/scroll-based-velocity.json

Some upstream demos use online images, videos or tweets. That content depends on network access and third-party services.

Scroll Based Velocity

Install: npx shadcn@latest add https://jiguang132.com/r/magic-ui/scroll-based-velocity.json

Use case

Move repeated rows in response to scroll velocity.

Native props used by the examples

Extracted from all local examples for this entry, grouped by imported module and native owner, including other Magic components used by compound demos. This is not an exhaustive API or a universal host variant. Inspect spread object declarations and the source types/defaults below.

Owning component propExplanationExample source
ScrollVelocityContainer.className (scroll-based-velocity)Classes on this native component; initialize Tailwind and its required CSS first.examples/scroll-based-velocity-demo.tsx、examples/scroll-based-velocity-images-demo.tsx
ScrollVelocityContainer.children (scroll-based-velocity)Native child content; keep the owning component's text/element constraints.examples/scroll-based-velocity-demo.tsx、examples/scroll-based-velocity-images-demo.tsx
ScrollVelocityRow.baseVelocity (scroll-based-velocity)Base horizontal movement speed for the scroll-reactive row.examples/scroll-based-velocity-demo.tsx、examples/scroll-based-velocity-images-demo.tsx
ScrollVelocityRow.direction (scroll-based-velocity)Native orientation/direction enum; values differ by component.examples/scroll-based-velocity-demo.tsx、examples/scroll-based-velocity-images-demo.tsx
ScrollVelocityRow.children (scroll-based-velocity)Native child content; keep the owning component's text/element constraints.examples/scroll-based-velocity-demo.tsx、examples/scroll-based-velocity-images-demo.tsx
ScrollVelocityRow.className (scroll-based-velocity)Classes on this native component; initialize Tailwind and its required CSS first.examples/scroll-based-velocity-images-demo.tsx

Interaction and state checks

  • Scroll Based Velocity Demo — scroll-based-velocity-demo
  • Scroll Based Velocity Images — scroll-based-velocity-images-demo

These names identify real example entries, not new component props or extra components. Check pointer/keyboard behavior, themes, small screens and failures for the selected example. Decorative effects must not invent disabled/error/submission states. Complete example installation includes the actual dependency closure.

Business integration boundary

ScrollVelocityContainer and ScrollVelocityRow are distinct native helpers. The scrolling document is the preview document, not its parent.

Host and motion setup

Initialize Tailwind CSS v4, semantic CSS variables and the dark variant; import the independent local Registry namespace. Reuse an existing next-themes Provider without substituting JGuang UI/Base UI/HeroUI APIs. Mount effects in view and unmount offscreen; provide static alternatives for unavailable Canvas/WebGL or failed remote media. Respect prefers-reduced-motion and verify timer/RAF/observer/listener cleanup: stopping CSS alone does not prove the engine stopped. Examples provide no backend, login, payment or real AI stream. This practical guide is bilingual; detailed upstream references and demo text retain their original language.

Available examples

scroll-based-velocity-demo, scroll-based-velocity-images-demo

Demo state and mock data do not provide a backend service. Inspect the component props before wiring real data.

Installation

<Tabs defaultValue="cli"> <TabsList> <TabsTrigger value="cli">CLI</TabsTrigger> <TabsTrigger value="manual">Manual</TabsTrigger> </TabsList> <TabsContent value="cli">
npx shadcn@latest add @magicui/scroll-based-velocity
</TabsContent> <TabsContent value="manual"> <Steps>

<Step>Install the following dependencies:</Step>

npm install motion

<Step>Copy and paste the following code into your project.</Step>

<Step>Update the import paths to match your project setup.</Step>

</Steps> </TabsContent> </Tabs>

Usage

import {
  ScrollVelocityContainer,
  ScrollVelocityRow,
} from "@/components/ui/scroll-based-velocity"
<ScrollVelocityContainer className="text-4xl font-bold md:text-7xl">
  <ScrollVelocityRow baseVelocity={20} direction={1}>
    Velocity Scroll
  </ScrollVelocityRow>
  <ScrollVelocityRow baseVelocity={20} direction={-1}>
    Velocity Scroll
  </ScrollVelocityRow>
</ScrollVelocityContainer>

Props

ScrollVelocityContainer

PropTypeDefaultDescription
classNamestring-The class name to be applied to the component
childrenReactNode-Content to be animated

ScrollVelocityRow

PropTypeDefaultDescription
classNamestring-The class name to be applied to the row container
childrenReactNode-Content to be duplicated and scrolled
baseVelocitynumber5Base scroll velocity percentage of content width
direction1 | -11Scroll direction (1 = left-to-right, -1 = reverse)
scrollReactivitybooleantrueToggles scroll interactivity

Performance

  • Pauses updates when offscreen and when the tab is hidden.
  • Respects user preference for reduced motion.

Complete example installation

The component command installs the component. Each example command also includes its actual imported components, native support UI, utilities and pinned dependencies. Helpers are not additional catalog components.

Scroll Based Velocity Demo

npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/scroll-based-velocity/scroll-based-velocity-demo.json

Default import: @/components/magicui/examples/scroll-based-velocity-demo

Dependencies: clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0

Scroll Based Velocity Images

npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/scroll-based-velocity/scroll-based-velocity-images-demo.json

Default import: @/components/magicui/examples/scroll-based-velocity-images-demo

Dependencies: clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0

Minimal usage and theme

import Demo from '@/components/magicui/examples/scroll-based-velocity-demo';
import { ThemeProvider } from 'next-themes';
export default function Example() {
  return <ThemeProvider attribute="class" defaultTheme="system" enableSystem><Demo /></ThemeProvider>;
}

Initialize Tailwind CSS v4, semantic color variables and the dark variant first. Reuse an existing next-themes provider rather than nesting another. Next Link examples require a Next.js environment; in static Vite projects adapt the demo links to your router without changing the native component API. Some media and tweets require network access. Examples do not supply authentication or backend services.

Source-backed parameter reference

Implementation signatures and types are generated from the pinned local source. Optional props, native inherited types, union branches and never exclusions are preserved. A forwardRef implementation's ref is a React reference, not an additional business prop.

ScrollVelocityContainer({
  children,
  className,
  ...props
}: React.HTMLAttributes<HTMLDivElement>)

ScrollVelocityRow(props: ScrollVelocityRowProps)
interface ScrollVelocityRowProps extends React.HTMLAttributes<HTMLDivElement> {
  children: React.ReactNode
  baseVelocity?: number
  direction?: 1 | -1
  scrollReactivity?: boolean
}

Native and external types

External types remain defined by React or native dependencies, not manually expanded into guessed props. The installed version's TypeScript definitions are authoritative.

React.HTMLAttributes<HTMLDivElement>
HTMLDivElement
React.ReactNode