LineItemsTable
The lines of an order, invoice or return: product and SKU, quantity, unit price, discount, VAT and total. It only shows the lines: the amounts come from your backend. prices="incl" or "excl" says whether the unit price and the total include VAT, and their headers say it too. The unit price keeps up to 6 decimals; the other amounts have 2. The discount and VAT columns show only when a line has a value. A returned quantity shows as a chip. href opens the line's record, rowActions adds a “⋯” menu, and on phones each line is a card. A line can also carry media (a small image at the start of the name), description (muted lines under the name), parts (the sub-lines of a kit, each with a name, an optional SKU and a quantity, without a price) and extra (more under the name: option chips, file thumbnails). They show in the card rows too. totals puts a TotalsList under the table at the end side, full width on narrow tables; empty replaces the rows when there are no lines.
import { LineItemsTable, type LineItem } from "@percentsa/ui";Examples
| Product | Qty | Unit price incl. VAT | Discount | VAT | Total incl. VAT | Row actions |
|---|---|---|---|---|---|---|
| Arabic coffee, 1 kgCOF-AR-1000 | Qty4 | Unit price incl. VAT89.50 | Discount0.00 | VAT46.70 | Total incl. VAT358.00 | |
| Paper cups, 8 ozReturned 50CUP-08 | Qty500 pcs | Unit price incl. VAT0.4565 | Discount10.00 | VAT28.47 | Total incl. VAT218.25 | |
| Dates, SukkariDAT-SUK | Qty2 | Unit price incl. VAT45.00 | Discount0.00 | VAT11.74 | Total incl. VAT90.00 |
Code
export function LineItemsTableExample() {
const t = useT();
return (
<LineItemsTable
className="w-full max-w-4xl"
caption={t("Order SO-1042", "الطلب SO-1042")}
prices="incl"
lines={[
{ id: "1", name: t("Arabic coffee, 1 kg", "قهوة عربية، 1 كغ"), sku: "COF-AR-1000", quantity: 4, unitPrice: 89.5, vat: 46.7, total: 358, href: "#COF-AR-1000" },
{ id: "2", name: t("Paper cups, 8 oz", "أكواب ورقية، 8 أونصات"), sku: "CUP-08", quantity: 500, unit: t("pcs", "قطعة"), unitPrice: 0.4565, discount: 10, vat: 28.47, total: 218.25, returned: 50 },
{ id: "3", name: t("Dates, Sukkari", "تمر سكري"), sku: "DAT-SUK", quantity: 2, unitPrice: 45, vat: 11.74, total: 90 },
]}
rowActions={() => [{ label: t("Return", "إرجاع"), onSelect: () => {} }]}
/>
);
}| Product | Qty | Unit price excl. VAT | Total excl. VAT |
|---|---|---|---|
Front brake kitKIT-FB-01VAT 15%
CeramicFront axle | Qty1 | Unit price excl. VAT200.00 | Total excl. VAT200.00 |
| Brake fluid, 1 LBF-1VAT 15% | Qty2 | Unit price excl. VAT25.00 | Total excl. VAT50.00 |
- Subtotal
- 250.00
- VAT15%
- 37.50
- Total
- 287.50
| Product | Qty | Unit price incl. VAT | Total incl. VAT |
|---|---|---|---|
No lines yet. Add a product to start. | |||
Code
export function LineItemsTableDetailsExample() {
const t = useT();
return (
<Stack gap={6} className="w-full max-w-4xl">
<LineItemsTable
caption={t("Quote QT-318", "عرض السعر QT-318")}
prices="excl"
lines={[
{
id: "1",
name: t("Front brake kit", "طقم فرامل أمامي"),
sku: "KIT-FB-01",
quantity: 1,
unitPrice: 200,
total: 200,
media: { alt: t("Front brake kit", "طقم فرامل أمامي") },
description: t("VAT 15%", "معدل الضريبة 15%"),
parts: [
{ id: "a", name: t("Brake disc", "قرص فرامل"), sku: "BD-12", quantity: 2 },
{ id: "b", name: t("Pad set", "طقم فحمات"), sku: "BP-01", quantity: 1 },
],
extra: (
<Inline gap={2}>
<Badge variant="outline">{t("Ceramic", "سيراميك")}</Badge>
<Badge variant="outline">{t("Front axle", "المحور الأمامي")}</Badge>
</Inline>
),
},
{ id: "2", name: t("Brake fluid, 1 L", "زيت فرامل، 1 لتر"), sku: "BF-1", quantity: 2, unitPrice: 25, total: 50, description: t("VAT 15%", "معدل الضريبة 15%") },
]}
totals={[
{ label: t("Subtotal", "المجموع"), amount: 250 },
{ label: t("VAT", "الضريبة"), amount: 37.5, hint: "15%" },
{ label: t("Total", "الإجمالي"), amount: 287.5, total: true },
]}
/>
<LineItemsTable caption={t("Return RT-12", "المرتجع RT-12")} prices="incl" lines={[]} empty={t("No lines yet. Add a product to start.", "لا توجد بنود بعد. أضف منتجًا للبدء.")} />
</Stack>
);
}
const PRODUCTS = [
{ value: "COF", en: "Arabic coffee, 1 kg", ar: "قهوة عربية، 1 كغ", price: 89.5 },
{ value: "CUP", en: "Paper cups, 8 oz", ar: "أكواب ورقية، 8 أونصات", price: 0.46 },
{ value: "DAT", en: "Dates, Sukkari", ar: "تمر سكري", price: 45 },
];
type EditorLine = { id: string; product: string; qty: string; price: string; note: string };
/** An invoice line editor: product pick (the focus moves on), quantity, price, a computed total, line details, a menu and the totals. */