Docs
Circling Elements

Circling Elements

A component that creates a circling effect on its children.

Inspiration from Bakken & Bæck

Installation


npx shadcn@latest add "https://fancycomponents.dev/r/circling-elements.json"

Usage


You only need to wrap your elements with the CirclingElements component, everything else is taken care of by the component itself.

Understanding the component


Under the hood, the component wraps all the children in a relative container, then sets all children to absolute to allow the circling movement.

The animation is achieved through CSS keyframes that create a circular motion. At the start (0%), each element is rotated by its offset angle, translated outward by the radius, and counter-rotated to maintain orientation. At the end (100%), it completes a full 360-degree rotation while maintaining the same radius and orientation. The --circling-direction variable allows reversing the animation direction.

The keyframes use CSS calc() to dynamically compute the transforms based on the following variables:

  • --circling-offset (element's starting angle)
  • --circling-radius (circle size)
  • --circling-direction (1 or -1 for direction)

Examples


Easing & direction

You can set custom easings and reverse direction for the animation, as you can see in this demo.

Props


PropTypeDefaultDescription

children*

ReactNode-The elements to be circled
radiusnumber100The radius of the circle in pixels
durationnumber10The duration of one complete rotation in seconds
easingstringlinear

The easing function for the animation. Refer to the official mdn docs for more details

direction"normal" | "reverse"normal

The direction of the animation. Set to "reverse" to reverse the animation

pauseOnHoverbooleanfalsePause the animation on hover
classNamestring-Additional CSS classes for the container

Credits


Inspiration for the demo from Bakken & Bæck