Installation
$ pnpm dlx shadcn@latest add @synccn/animated-beamFirst time in this project? Connect synccn with one command.
Usage
import { AnimatedBeam } from "@/components/ui/animated-beam";<AnimatedBeam containerRef={box} fromRef={a} toRef={b} />API reference
Generated from the component's TypeScript types, so it always matches the code.
AnimatedBeam
Curved line between two elements with a light travelling along it. Pass refs to a shared relative container and to both ends.
- containerRefrequired
React.RefObject<HTMLElement | null>Relatively positioned element that holds both ends.
- fromRefrequired
React.RefObject<HTMLElement | null>Element where the beam starts.
- toRefrequired
React.RefObject<HTMLElement | null>Element where the beam ends.
- curvature
numberDefault
0How far the curve bends, in pixels. Negative bends downwards.
- reverse
booleanDefault
falseRun the light from the end back to the start.
- duration
numberDefault
3Seconds for one pass of the light.
- delay
numberDefault
0Seconds before the first pass.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Helpers
- lib/utilscn (merges class names)
npm packages
- clsx for cn()
- tailwind-merge for cn()
Accessibility
From the source
Read from this component's code when the site builds, so it can't drift.
No ARIA roles, key handling or motion settings in its source. It renders plain elements, so its accessibility comes from the content and labels you give it.