MCPcopy Create free account
hub / github.com/MagicCube/agentara / ShimmerComponent

Function ShimmerComponent

web/src/components/ai-elements/shimmer.tsx:35–76  ·  view source on GitHub ↗
({
  children,
  as: Component = "p",
  className,
  duration = 2,
  spread = 2,
}: TextShimmerProps)

Source from the content-addressed store, hash-verified

33}
34
35const ShimmerComponent = ({
36 children,
37 as: Component = "p",
38 className,
39 duration = 2,
40 spread = 2,
41}: TextShimmerProps) => {
42 const MotionComponent = getMotionComponent(
43 Component as keyof JSX.IntrinsicElements
44 );
45
46 const dynamicSpread = useMemo(
47 () => (children?.length ?? 0) * spread,
48 [children, spread]
49 );
50
51 return (
52 <MotionComponent
53 animate={{ backgroundPosition: "0% center" }}
54 className={cn(
55 "relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent",
56 "[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",
57 className
58 )}
59 initial={{ backgroundPosition: "100% center" }}
60 style={
61 {
62 "--spread": `${dynamicSpread}px`,
63 backgroundImage:
64 "var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))",
65 } as CSSProperties
66 }
67 transition={{
68 duration,
69 ease: "linear",
70 repeat: Number.POSITIVE_INFINITY,
71 }}
72 >
73 {children}
74 </MotionComponent>
75 );
76};
77
78export const Shimmer = memo(ShimmerComponent);

Callers

nothing calls this directly

Calls 2

cnFunction · 0.90
getMotionComponentFunction · 0.85

Tested by

no test coverage detected