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-folderUsage
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
| Prop | Type | Default |
|---|---|---|
itemThe tile you drag: { label, sublabel?, color, image?, badge? }. | FolderTile | — |
targetThe tile you drop onto. | FolderTile | — |
folderLabelLabel under the finished folder. | string | "untitled folder" |
hoverLabelLabel under the target while hovering. | string | "Add to folder" |
countLabelSub-label under the folder and hover label. | string | "2 items" |
onFolderCreatedCalled when the tile is dropped onto the target. | () => void | — |
liftProgressGoes 0 → 1 while a tile is held. Pass your own to animate other UI. | SharedValue<number> | — |
tileSizeTile size. | number | 120 |
gapSpace between the tiles. | number | 22 |
folderColorFolder background. | string | "#ececee" |
textColorLabel colour. | string | "#111" |
subTextColorSub-label colour. | string | "#8e8e93" |