|
| 1 | +--- |
| 2 | +title: Text 3D Flip |
| 3 | +date: 2026-04-05 |
| 4 | +description: A text effect that flips each letter in 3D with a staggered animation on hover. |
| 5 | +author: aayushbharti |
| 6 | +published: true |
| 7 | +--- |
| 8 | + |
| 9 | +<ComponentPreview name="text-3d-flip-demo" /> |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +<Tabs defaultValue="cli"> |
| 14 | + |
| 15 | +<TabsList> |
| 16 | + <TabsTrigger value="cli">CLI</TabsTrigger> |
| 17 | + <TabsTrigger value="manual">Manual</TabsTrigger> |
| 18 | +</TabsList> |
| 19 | +<TabsContent value="cli"> |
| 20 | + |
| 21 | +```bash |
| 22 | +npx shadcn@latest add @magicui/text-3d-flip |
| 23 | +``` |
| 24 | + |
| 25 | +</TabsContent> |
| 26 | + |
| 27 | +<TabsContent value="manual"> |
| 28 | + |
| 29 | +<Steps> |
| 30 | + |
| 31 | +<Step>Copy and paste the following code into your project.</Step> |
| 32 | + |
| 33 | +<ComponentSource name="text-3d-flip" /> |
| 34 | + |
| 35 | +<Step>Update the import paths to match your project setup.</Step> |
| 36 | + |
| 37 | +</Steps> |
| 38 | + |
| 39 | +</TabsContent> |
| 40 | + |
| 41 | +</Tabs> |
| 42 | + |
| 43 | +## Usage |
| 44 | + |
| 45 | +```tsx showLineNumbers |
| 46 | +import Text3DFlip from "@/components/ui/text-3d-flip" |
| 47 | +``` |
| 48 | + |
| 49 | +```tsx showLineNumbers |
| 50 | +<Text3DFlip |
| 51 | + className="bg-background" |
| 52 | + textClassName="bg-background text-foreground" |
| 53 | + flipTextClassName="bg-background text-foreground" |
| 54 | + rotateDirection="top" |
| 55 | +> |
| 56 | + Stay hungry, stay foolish |
| 57 | +</Text3DFlip> |
| 58 | +``` |
| 59 | + |
| 60 | +## Examples |
| 61 | + |
| 62 | +### Stagger from center |
| 63 | + |
| 64 | +<ComponentPreview name="text-3d-flip-demo-2" /> |
| 65 | + |
| 66 | +## Props |
| 67 | + |
| 68 | +| Prop | Type | Default | Description | |
| 69 | +| ------------------- | ----------------------------------------------------- | ------------------------------------------------- | --------------------------------------------------------------------------------------------- | |
| 70 | +| `children`\* | `ReactNode` | `-` | The content to be displayed and animated | |
| 71 | +| `as` | `ElementType` | `"p"` | HTML element to render the component as | |
| 72 | +| `className` | `string` | `-` | Class name for the main container element | |
| 73 | +| `textClassName` | `string` | `-` | Class name for each letter (visible before flip) | |
| 74 | +| `flipTextClassName` | `string` | `-` | Class name for each letter (revealed after flip) | |
| 75 | +| `staggerDuration` | `number` | `0.05` | Duration of stagger delay between each letter in seconds | |
| 76 | +| `staggerFrom` | `"first" \| "last" \| "center" \| number \| "random"` | `"first"` | Direction to stagger animations from. Use a number to stagger from a specific character index | |
| 77 | +| `transition` | `ValueAnimationTransition \| AnimationOptions` | `{ type: "spring", damping: 30, stiffness: 300 }` | Animation transition configuration from Motion | |
| 78 | +| `rotateDirection` | `"top" \| "right" \| "bottom" \| "left"` | `"right"` | Direction of 3D rotation on hover | |
| 79 | + |
| 80 | +## Credits |
| 81 | + |
| 82 | +- Credit to [@AayushBharti](https://github.com/AayushBharti) |
0 commit comments