Cradle Text - React Component | Kokonut UI
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
Cradle Text is a free, open-source React component in the Kokonut UI Texts collection. Add it with the shadcn CLI, which copies the source into components/kokonutui/cradle-text.tsx, so the code is yours to change.
npx shadcn@latest add @kokonutui/cradle-text
Usage
import CradleText from "@/components/kokonutui/cradle-text";
export default function Example() {
return <CradleText />;
}
Props
text
- Type:
string - Default:
"Momentum"- The line of letters hung from the rail. Keep it to one line.
className
- Type:
string- Extra classes for the root element.
intro
- Type:
boolean - Default:
true- Lift the first letter and let it go once, the first time it's seen.
bounce
- Type:
number - Default:
0.97- How much speed a collision keeps, 0 to 1. Steel is about 0.95.
Dependencies
| Needs | Version | Comes from |
|---|---|---|
cn from lib/utils.ts |
shadcn init | |
| React | 19 |
Your app |
| Tailwind CSS | 4 |
Your app |
No provider, font or global CSS to set up: the file works as soon as it lands.
Related Text
- [Plucked Text
A headline sitting on a string you can pluck, strum and let ring, built with React and real string physics.](/content/docs/texts/plucked-text/index.html)
- [Spoiler Text
Inline text hidden under drifting specks, like a chat spoiler. A click blows the specks away from the point you touched.](/content/docs/texts/spoiler-text/index.html)