Trash list
Deleted items with who and when, days left, restore, delete forever and empty trash.
import { TrashList, retentionDaysLeft, retentionText, sortByRetention } from "@forgeron/ui";- Old onboarding checklist2 days left
- Q3 planning13 days left
- Acme renewal28 days left
- Invoice 21429 days left
import { TrashList, type TrashEntry } from "@forgeron/ui";
import { useState } from "react";
const initial: TrashEntry[] = [
{
id: "a",
name: "Invoice 214",
kind: "Invoice",
deletedBy: "Ada Lovelace",
deletedAt: "2026-11-18",
},
{
id: "b",
name: "Q3 planning",
kind: "Document",
deletedBy: "Sam Roche",
deletedAt: "2026-11-02",
},
{
id: "c",
name: "Old onboarding checklist",
kind: "Document",
deletedBy: "Léa Martin",
deletedAt: "2026-10-22",
},
{
id: "d",
name: "Acme renewal",
kind: "Project",
deletedBy: "Ada Lovelace",
deletedAt: "2026-11-17",
},
];
export default function Default() {
const [items, setItems] = useState(initial);
const drop = (ids: string[]) => setItems(items.filter((i) => !ids.includes(i.id)));
return (
<div style={{ width: "100%", maxWidth: 760 }}>
<TrashList
items={items}
today="2026-11-19"
onRestore={drop}
onDeleteForever={drop}
onEmpty={() => setItems([])}
/>
</div>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | { id, name, kind?, deletedBy, deletedAt }[] | — | The soonest to go first. |
today | string | — | YYYY-MM-DD: dates are told from it (“3 days ago”, “In 5 days”). |
retentionDays | number | 30 | Days before it is deleted for good. |
onRestore | (ids: string[]) => void | — | One id from a row, several from the selection. |
onDeleteForever | (ids: string[]) => void | — | After the confirmation. |
onEmpty | () => void | — | Empty trash, after the confirmation; without it, no button. |
notice / noun / empty | boolean; string; string | — | The retention banner; the word for one item. |
className | string | — | Extra classes. |