Text Circle Scroll
shadcn-extras/text-circle-scrollFreeComponent
Circular text/nodes that rotate with scroll and/or auto-spin.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/NayanDevLab/shadcn-extras/dev/public/c/text-circle-scroll.jsonSource
1'use client';23import * as React from 'react';4import { motion, useScroll, useTransform, useSpring } from 'motion/react';5import { cn } from '@/lib/utils';67export type TextCircleItem = string | React.ReactNode;89export type TextCircleScrollProps = {10 /** Items placed on the ring in order (clockwise by default). */11 items: TextCircleItem[];1213 /** Radius in px (distance from center to baseline of items). */14 radius?: number;1516 /** Empty hole diameter in px (purely visual helper class on container). */17 innerGap?: number;1819 /** Angle offset in degrees for the first item. */20 startAngle?: number;2122 /** Clockwise (true) or counter-clockwise (false) item order. */23 clockwise?: boolean;2425 /** If true, connects rotation to page scroll progress. */26 rotateOnScroll?: boolean;2728 /**29 * How many degrees the ring rotates from top->bottom of the page when30 * rotateOnScroll = true. 360 = one full turn.31 */32 scrollDegrees?: number;3334 /** Constant rotation (deg/s). Can be negative for reverse. */35 autoSpinDegPerSec?: number;3637 /** Springiness for scroll rotation. Set 0 to disable spring. */38 springStiffness?: number;3940 /** Container className */41 className?: string;4243 /** Ring element className */44 ringClassName?: string;4546 /** Per-item className */47 itemClassName?: string;4849 /** Typography class for items (e.g. 'text-lg font-serif') */50 textClassName?: string;5152 /** If provided, constrain the component height (useful in docs/examples). */53 height?: number | string;54};5556/**57 * TextCircleScroll58 * - Places any text/nodes around a circle59 * - Rotates with scroll (and/or auto-spin)60 * - Purely presentational; does not manage layout outside itself61 */62export default function TextCircleScroll({63 items,64 radius = 110,65 innerGap = 90,66 startAngle = -90,67 clockwise = true,68 rotateOnScroll = true,69 scrollDegrees = 360,70 autoSpinDegPerSec = 0,71 springStiffness = 120,72 className,73 ringClassName,74 itemClassName,75 textClassName = 'text-base font-serif text-zinc-800 dark:text-zinc-200',76 height = 320,77}: TextCircleScrollProps) {78 const ref = React.useRef<HTMLDivElement>(null);7980 // --- Scroll-driven rotation81 const { scrollYProgress } = useScroll({82 // when the component is within the viewport83 target: ref,84 offset: ['start end', 'end start'],85 });8687 const rawRotate = useTransform(scrollYProgress, [0, 1], [0, scrollDegrees]);88 const rotateSpring = useSpring(rawRotate, {89 stiffness: springStiffness || 120,90// … truncated
What it pulls in
npm packages
Files it writes
More from shadcn-extras
All 33 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Image Gridanimated-image-grid | shadcn-extras | Components | Free | no deps · 3 files | |
| Blog Card Fourblog-card-four | shadcn-extras | Components | Free | 1 dep | |
| Blog Card Oneblog-card-one | shadcn-extras | Components | Free | no deps | |
| Blog Card Threeblog-card-three | shadcn-extras | Components | Free | 1 dep | |
| Blog Card Twoblog-card-two | shadcn-extras | Components | Free | 1 dep | |
| Bulb Iconbulb-icon | shadcn-extras | Components | Free | 2 deps | |
| Chevron Stepschevron-steps | shadcn-extras | Components | Free | no deps | |
| Circular Gallerycircular-gallery | shadcn-extras | Components | Free | no deps · 3 files |
