Kinetic UI
Back to Introduction
Physics & Micro-Interactions

Destructible UI

A lightweight, physics-inspired wrapper that shatters your React components into geometric shards upon interaction.

Quick Actions
CLI Installation
npx kinetic-ui-cli@latest add destructible-ui
Destructible UI

Delete Project

This action cannot be undone and will permanently shatter this component.

Installation

npx kinetic-ui-cli@latest add destructible-ui

Architecture

This component is incredibly lightweight compared to traditional physics engines (like matter.js). Instead of simulating 2D bodies, it uses a brilliant illusion:

  1. It renders your children exactly as normal.
  2. When isDestroyed becomes true, it immediately sets the original component to opacity-0 (so it maintains its exact layout footprint in the DOM without shifting neighboring elements).
  3. Simultaneously, it mounts 5 absolute clones of your component perfectly overlaid on top.
  4. Each clone is masked via a CSS clip-path polygon to represent a shard of glass.
  5. 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>
  );
}
Performance Notes
  • Uses CSS hardware acceleration via GPU transform-binds.
  • Damped interpolation minimizes paint-redraw flashes.
  • Tree-shakable import: only compiles elements requested.
Accessibility Notes
  • Full keyboard focus-ring navigation support (`Tab`/`Shift+Tab`).
  • ARIA roles mapped correctly for assistive screen readers.
  • Respects `prefers-reduced-motion` system toggles.