Delete Project
This action cannot be undone and will permanently shatter this component.
Installation
npx kinetic-ui-cli@latest add destructible-uiArchitecture
This component is incredibly lightweight compared to traditional physics engines (like matter.js). Instead of simulating 2D bodies, it uses a brilliant illusion:
- It renders your
childrenexactly as normal. - When
isDestroyedbecomestrue, it immediately sets the original component toopacity-0(so it maintains its exact layout footprint in the DOM without shifting neighboring elements). - Simultaneously, it mounts 5 absolute clones of your component perfectly overlaid on top.
- Each clone is masked via a CSS
clip-pathpolygon to represent a shard of glass. - Framer Motion applies gravity, translation, and rotation to each clone individually, causing them to shatter outwards and fall.
Props
| Prop | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| children | React.ReactNode | | The component to wrap and shatter. |
| isDestroyed | boolean | | State controlling whether the component is whole or shattered. |
| force | number | 1 | Multiplier for the explosion radius and gravity speed. |
Usage Guide
1. Import the Component
Import the component into your React or Next.js page:
import { DestructibleUi } from "@/components/creative/destructible-ui";
2. Implementation Example
Render the component and customize its behavior by passing props:
import { DestructibleUi } from "@/components/creative/destructible-ui";
export default function Example() {
return (
<div className="w-full flex items-center justify-center p-8">
<DestructibleUi
>
<div>Content goes here</div>
</DestructibleUi>
</div>
);
}