UIR

DragToFolder

Two home-screen tiles. Hold the right tile to pick it up and drag it onto the left one: the target tucks into a corner, a folder appears, and dropping merges them.

Preview

Installation

npx @codewithrabby/ui@latest add drag-to-folder

Usage

import { DragToFolder } from "@/components/uir/drag-to-folder";

const [round, setRound] = useState(0);
const lifted = useSharedValue(0); // optional: animate your own UI while a tile is held

<DragToFolder
  key={round} // change the key to reset
  liftProgress={lifted}
  target={{ label: "Second", color: "#b321e0" }}
  item={{ label: "First", color: "#f06ad0", image: require("./cover.jpg") }}
  onFolderCreated={() => console.log("folder!")}
/>

Props

PropTypeDefault
item

The tile you drag: { label, sublabel?, color, image?, badge? }.

FolderTile—
target

The tile you drop onto.

FolderTile—
folderLabel

Label under the finished folder.

string"untitled folder"
hoverLabel

Label under the target while hovering.

string"Add to folder"
countLabel

Sub-label under the folder and hover label.

string"2 items"
onFolderCreated

Called when the tile is dropped onto the target.

() => void—
liftProgress

Goes 0 → 1 while a tile is held. Pass your own to animate other UI.

SharedValue<number>—
tileSize

Tile size.

number120
gap

Space between the tiles.

number22
folderColor

Folder background.

string"#ececee"
textColor

Label colour.

string"#111"
subTextColor

Sub-label colour.

string"#8e8e93"