klyv-ui

Falling Sand

Heroes 8

About

An interactive falling-sand cellular automaton where sand, water, oil, wood, stone, fire, smoke and steam fall, pile and react on a canvas grid that a user can paint, pour or drop material into.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Falling Sand to your project and fits it to your theme.

Code

How Falling Sand is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { FallingSand } from "@/components/ui/klyv-falling-sand";
import type { FallingSandHandle } from "@/components/ui/klyv-falling-sand";
import { useRef } from "react";
import { Button } from "@/components/ui/klyv-falling-sand-utils/button";

export default function FallingSandDemo() {
  const sand = useRef<FallingSandHandle>(null);
  return (
    <div className="flex w-full flex-col gap-3 p-6">
      <FallingSand
        ref={sand}
        seedText={"Built grain\nby grain"}
        controls={false}
        label="Sand box with a headline made of packed sand. Drag to pour sand onto it."
        className="h-[420px]"
      />
      <div className="flex flex-wrap items-center gap-2">
        <Button size="sm" onClick={() => sand.current?.pour(4)}>
          Pour sand on it
        </Button>
        <Button
          size="sm"
          variant="outline"
          onClick={() => sand.current?.pour(4, "water")}
        >
          Pour water
        </Button>
        <Button
          size="sm"
          variant="outline"
          onClick={() => sand.current?.drop(0.5, 0.12, "sand")}
        >
          Drop a handful
        </Button>
        <Button size="sm" variant="ghost" onClick={() => sand.current?.reset()}>
          Rebuild the words
        </Button>
      </div>
    </div>
  );
}

More by klyv-ui

View all
  • Gantt Chart

    Gantt Chart

    106
  • Shader Canvas

    Shader Canvas

    69
  • Klyv Animated Beam

    Klyv Animated Beam

    68
  • Pareto Chart

    Pareto Chart

    60
  • Fluid Canvas

    Fluid Canvas

    44
  • Sunburst Chart

    Sunburst Chart

    35
  • Time Slot Picker

    Time Slot Picker

    32
  • Morphing Text

    Morphing Text

    32

More in Heroes

View all
  • Agency Hero Section

    Agency Hero Section

    1.1K
  • Responsive Hero Banner

    Responsive Hero Banner

    2.2K
  • SaaS Template

    SaaS Template

    2.7K
  • Centered Hero with Image Fan

    Centered Hero with Image Fan

    1.1K
  • Hero

    Hero

    1.4K
  • Hero Section 01

    Hero Section 01

    56
  • Split Hero With Image Cards

    Split Hero With Image Cards

    467
  • Facts Hero

    Facts Hero

    6