klyv-ui

Falling Sand

Heroes

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

    89
  • Shader Canvas

    Shader Canvas

    60
  • Klyv Animated Beam

    Klyv Animated Beam

    59
  • Pareto Chart

    Pareto Chart

    53
  • Fluid Canvas

    Fluid Canvas

    37
  • Sunburst Chart

    Sunburst Chart

    30
  • Gooey Loader

    Gooey Loader

    28
  • Morphing Text

    Morphing Text

    27

More in Heroes

View all
  • Responsive Hero Banner

    Responsive Hero Banner

    2.1K
  • SaaS Template

    SaaS Template

    2.6K
  • Hero 03

    Hero 03

    353
  • Hero

    Hero

    1.3K
  • Centered Hero with Image Fan

    Centered Hero with Image Fan

    1K
  • Hero Section

    Hero Section

    438
  • Hero with text and two button

    Hero with text and two button

    115
  • Editorial Collage Hero

    Editorial Collage Hero

    482