cradle text.md
Cradle Text
A headline hung like a Newton's cradle, so a knock on one letter clacks through the word, built with React and pendulum physics.
Installation
npx shadcn@latest add @kokonutui/cradle-text
Props
| Prop | Type | Default | Description |
|---|---|---|---|
text? |
string |
"Momentum" |
The line of letters hung from the rail. Keep it to one line. |
className? |
string |
Extra classes for the root element. | |
intro? |
boolean |
true |
Lift the first letter and let it go once, the first time it's seen. |
bounce? |
number |
0.97 |
How much speed a collision keeps, 0 to 1. Steel is about 0.95. |
Source
"use client";
/**
* @author: @dorianbaffier
* @description: Cradle Text
* @version: 1.0.0
* @date: 2026-10-15
* @license: MIT
* @website: https://kokonutui.com
* @github: https://github.com/kokonut-labs/kokonutui
*/
import { useEffect, useRef } from "react";
import { cn } from "@/lib/utils";
export interface CradleTextProps {
/** The line of letters hung from the rail. Keep it to one line. */
text?: string;
className?: string;
/** Lift the first letter and let it go once, the first time it's seen. */
intro?: boolean;
/** How much speed a collision keeps, 0 to 1. Steel is about 0.95. */
bounce?: number;
}
// ... (rest of the code is omitted for brevity)
export default function CradleText({
text = "Momentum",
className,
intro = true,
bounce = 0.97,
}: CradleTextProps) {
// ... (rest of the component implementation)
}