List
Rows with an icon, title, description and a trailing value or action, with dividers between them. With href a row is one link. With onSelect a row is one button instead (the title is its text; controls in trailing still work), and disabled dims it. move adds move up and move down buttons for an ordered list: you pass the row's index, the count and onMove(from, to), and reorder in your state (give the rows stable keys, and data-flip to make them glide). The first row's up button and the last row's down button are disabled. After the move the focus stays on the same button (on the other one when the row reaches an end) and the new place is announced in the page language (one live region per List); label names the row (default: the title when it is a string). Inside data-density="touch" the rows and buttons are finger-sized on a touch screen.
import { List, ListItem } from "@percentsa/ui";Examples
- Bayt CoffeeOnline store · in progress
- Project proposalPDF · 2.4 MB
Code
export function ListExample() {
const t = useT();
return (
<List className="w-full max-w-md">
<ListItem
href="#"
leading={<Smartphone aria-hidden />}
title={t("Masar", "مسار")}
description={t("Booking app · 2026", "تطبيق حجوزات · 2026")}
trailing={<StatusDot status="live">{t("Live", "يعمل")}</StatusDot>}
/>
<ListItem
href="#"
leading={<LayoutDashboard aria-hidden />}
title={t("Sadeem", "سديم")}
description={t("Operations dashboard · 2025", "لوحة عمليات · 2025")}
trailing={<Money amount={180000} />}
/>
<ListItem
leading={<Globe aria-hidden />}
title={t("Bayt Coffee", "قهوة بيت")}
description={t("Online store · in progress", "متجر إلكتروني · قيد التنفيذ")}
trailing={<Button size="sm" variant="ghost">{t("Open", "فتح")}</Button>}
/>
<ListItem leading={<FileText aria-hidden />} title={t("Project proposal", "عرض المشروع")} description={<span dir="ltr">PDF · 2.4 MB</span>} />
</List>
);
}
/** An ordered list: `move` adds the up and down buttons. The app reorders; rows have stable keys and `data-flip` so they glide. */0 in the cart
Code
export function ListPickExample() {
const t = useT();
const [cart, setCart] = useState<string[]>([]);
return (
<div data-density="touch" className="grid w-full max-w-md gap-3">
<List className="rounded-card border border-line">
{PRODUCTS.map((p) => (
<ListItem
key={p.id}
title={t(p.en, p.ar)}
description={<span dir="ltr">{p.id.toUpperCase()}</span>}
trailing={<Money amount={p.price} />}
disabled={p.stock <= 0}
onSelect={() => setCart((c) => [...c, p.id])}
/>
))}
</List>
<div className="flex items-center justify-between gap-3">
<Text size="sm" tone="muted" aria-live="polite">
{t(`${cart.length} in the cart`, `${cart.length} في السلة`)}
</Text>
<Button size="sm" variant="secondary" onClick={() => setCart([])} disabled={cart.length === 0}>
{t("Clear", "مسح")}
</Button>
</div>
</div>
);
}
/** A pickable tile: the image fills the width, the whole card is one button, a sold-out product is dim and does nothing. */- Delivery
- Returns
- Warranty
Code
export function ListMoveExample() {
const t = useT();
const [rows, setRows] = useState([
{ id: "a", en: "Delivery", ar: "التوصيل" },
{ id: "b", en: "Returns", ar: "المرتجعات" },
{ id: "c", en: "Warranty", ar: "الضمان" },
]);
return (
<List className="w-full max-w-md">
{rows.map((r, i) => (
<ListItem
key={r.id}
data-flip={r.id}
title={t(r.en, r.ar)}
move={{
index: i,
count: rows.length,
onMove: (from, to) =>
setRows((x) => {
const n = [...x];
n.splice(to, 0, ...n.splice(from, 1));
return n;
}),
}}
/>
))}
</List>
);
}
const PADS = "data:image/svg+xml," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 6"><rect width="8" height="6" fill="#888"/><circle cx="4" cy="3" r="1.8" fill="#ccc"/></svg>');
const PRODUCTS = [
{ id: "bp-01", en: "Front brake pads", ar: "فحمات أمامية", stock: 12, price: 230 },
{ id: "of-22", en: "Oil filter", ar: "فلتر زيت", stock: 40, price: 35 },
{ id: "sp-08", en: "Spark plug set", ar: "طقم شمعات", stock: 0, price: 120 },
{ id: "wb-03", en: "Wiper blades", ar: "مساحات زجاج", stock: 7, price: 60 },
];
/** A product list for a counter tablet: `data-density="touch"` gives finger-sized controls on a touch screen, and each row is one button. */