Text 3D Flip
Install: npx shadcn@latest add https://jiguang132.com/r/magic-ui/text-3d-flip.json
Use case
Flip text segments in 3D on hover.
Native props used by the examples
Extracted from all local examples for this entry, grouped by imported module and native owner, including other Magic components used by compound demos. This is not an exhaustive API or a universal host variant. Inspect spread object declarations and the source types/defaults below.
| Owning component prop | Explanation | Example source |
|---|---|---|
Text3DFlip.className (text-3d-flip) | Classes on this native component; initialize Tailwind and its required CSS first. | examples/text-3d-flip-demo.tsx、examples/text-3d-flip-demo-2.tsx |
Text3DFlip.textClassName (text-3d-flip) | Classes applied to the visible Text3DFlip text segments. | examples/text-3d-flip-demo.tsx、examples/text-3d-flip-demo-2.tsx |
Text3DFlip.flipTextClassName (text-3d-flip) | Classes applied to the flipped Text3DFlip segments. | examples/text-3d-flip-demo.tsx、examples/text-3d-flip-demo-2.tsx |
Text3DFlip.rotateDirection (text-3d-flip) | Native 3D flip direction enum. | examples/text-3d-flip-demo.tsx、examples/text-3d-flip-demo-2.tsx |
Text3DFlip.staggerDuration (text-3d-flip) | Delay in seconds between flipped segments. | examples/text-3d-flip-demo.tsx、examples/text-3d-flip-demo-2.tsx |
Text3DFlip.staggerFrom (text-3d-flip) | Native stagger origin/order, including index or random. | examples/text-3d-flip-demo.tsx、examples/text-3d-flip-demo-2.tsx |
Text3DFlip.transition (text-3d-flip) | Native Motion transition object; preserve its own supported type. | examples/text-3d-flip-demo.tsx |
Text3DFlip.children (text-3d-flip) | Native child content; keep the owning component's text/element constraints. | examples/text-3d-flip-demo.tsx、examples/text-3d-flip-demo-2.tsx |
Interaction and state checks
- Text 3D Flip Demo —
text-3d-flip-demo - Text 3D Flip Demo 2 —
text-3d-flip-demo-2
These names identify real example entries, not new component props or extra components. Check pointer/keyboard behavior, themes, small screens and failures for the selected example. Decorative effects must not invent disabled/error/submission states. Complete example installation includes the actual dependency closure.
Business integration boundary
staggerFrom chooses segment order; transition uses native Motion options. Provide equivalent static content for non-hover/reduced-motion use.
Host and motion setup
Initialize Tailwind CSS v4, semantic CSS variables and the dark variant; import the independent local Registry namespace. Reuse an existing next-themes Provider without substituting JGuang UI/Base UI/HeroUI APIs. Mount effects in view and unmount offscreen; provide static alternatives for unavailable Canvas/WebGL or failed remote media. Respect prefers-reduced-motion and verify timer/RAF/observer/listener cleanup: stopping CSS alone does not prove the engine stopped. Examples provide no backend, login, payment or real AI stream. This practical guide is bilingual; detailed upstream references and demo text retain their original language.
Available examples
text-3d-flip-demo, text-3d-flip-demo-2
Demo state and mock data do not provide a backend service. Inspect the component props before wiring real data.
Installation
<Tabs defaultValue="cli"> <TabsList> <TabsTrigger value="cli">CLI</TabsTrigger> <TabsTrigger value="manual">Manual</TabsTrigger> </TabsList> <TabsContent value="cli">npx shadcn@latest add @magicui/text-3d-flip
</TabsContent>
<TabsContent value="manual">
<Steps>
<Step>Copy and paste the following code into your project.</Step>
<Step>Update the import paths to match your project setup.</Step>
</Steps> </TabsContent> </Tabs>Usage
import Text3DFlip from "@/components/ui/text-3d-flip"
<Text3DFlip
className="bg-background"
textClassName="bg-background text-foreground"
flipTextClassName="bg-background text-foreground"
rotateDirection="top"
>
Stay hungry, stay foolish
</Text3DFlip>
Examples
Stagger from center
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children* | ReactNode | - | The content to be displayed and animated |
as | ElementType | "p" | HTML element to render the component as |
className | string | - | Class name for the main container element |
textClassName | string | - | Class name for each letter (visible before flip) |
flipTextClassName | string | - | Class name for each letter (revealed after flip) |
staggerDuration | number | 0.05 | Duration of stagger delay between each letter in seconds |
staggerFrom | "first" | "last" | "center" | number | "random" | "first" | Direction to stagger animations from. Use a number to stagger from a specific character index |
transition | ValueAnimationTransition | AnimationOptions | { type: "spring", damping: 30, stiffness: 300 } | Animation transition configuration from Motion |
rotateDirection | "top" | "right" | "bottom" | "left" | "right" | Direction of 3D rotation on hover |
Credits
- Credit to @AayushBharti
Complete example installation
The component command installs the component. Each example command also includes its actual imported components, native support UI, utilities and pinned dependencies. Helpers are not additional catalog components.
Text 3D Flip Demo
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/text-3d-flip/text-3d-flip-demo.json
Default import: @/components/magicui/examples/text-3d-flip-demo
Dependencies: clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0
Text 3D Flip Demo 2
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/text-3d-flip/text-3d-flip-demo-2.json
Default import: @/components/magicui/examples/text-3d-flip-demo-2
Dependencies: clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0
Minimal usage and theme
import Demo from '@/components/magicui/examples/text-3d-flip-demo';
import { ThemeProvider } from 'next-themes';
export default function Example() {
return <ThemeProvider attribute="class" defaultTheme="system" enableSystem><Demo /></ThemeProvider>;
}
Initialize Tailwind CSS v4, semantic color variables and the dark variant first. Reuse an existing next-themes provider rather than nesting another. Next Link examples require a Next.js environment; in static Vite projects adapt the demo links to your router without changing the native component API. Some media and tweets require network access. Examples do not supply authentication or backend services.
Source-backed parameter reference
Implementation signatures and types are generated from the pinned local source. Optional props, native inherited types, union branches and never exclusions are preserved. A forwardRef implementation's ref is a React reference, not an additional business prop.
Text3DFlip({
children,
as: ElementTag = "p",
className,
textClassName,
flipTextClassName,
staggerDuration = 0.05,
staggerFrom = "first",
transition = DEFAULT_TRANSITION,
rotateDirection = "right",
...props
}: Text3DFlipProps)
interface Text3DFlipProps {
children: React.ReactNode
as?: ElementType
className?: string
textClassName?: string
flipTextClassName?: string
staggerDuration?: number
staggerFrom?: "first" | "last" | "center" | number | "random"
transition?: ValueAnimationTransition | AnimationOptions
rotateDirection?: "top" | "right" | "bottom" | "left"
}
Destructuring defaults in source
Only defaults written directly in parameter/props destructuring are listed. Conditional expressions, runtime theme and computed values require source inspection; this is not an exhaustive behavior-default list.
// Text3DFlip
as = "p"
// Text3DFlip
staggerDuration = 0.05
// Text3DFlip
staggerFrom = "first"
// Text3DFlip
transition = DEFAULT_TRANSITION
// Text3DFlip
rotateDirection = "right"
Native and external types
External types remain defined by React or native dependencies, not manually expanded into guessed props. The installed version's TypeScript definitions are authoritative.
React.ReactNode
ElementType
ValueAnimationTransition
AnimationOptions