A responsive table component.
<Table>
<TableCaption>A list of your recent invoices.</TableCaption>
<TableHeader>
<TableRow>
<TableHead Class="w-[100px]">Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead>Method</TableHead>
<TableHead Class="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
@foreach (var invoice in Invoices)
{
<TableRow>
<TableCell Class="font-medium">@invoice.Invoice</TableCell>
<TableCell>@invoice.PaymentStatus</TableCell>
<TableCell>@invoice.PaymentMethod</TableCell>
<TableCell Class="text-right">@invoice.TotalAmount</TableCell>
</TableRow>
}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colspan="3">Total</TableCell>
<TableCell Class="text-right">$2,500.00</TableCell>
</TableRow>
</TableFooter>
</Table>
@code {
private sealed record InvoiceEntry(string? Invoice, string? PaymentStatus, string? TotalAmount, string? PaymentMethod);
private static readonly InvoiceEntry[] Invoices =
[
new("INV001", "Paid", "$250.00", "Credit Card"),
new("INV002", "Pending", "$150.00", "PayPal"),
new("INV003", "Unpaid", "$350.00", "Bank Transfer"),
new("INV004", "Paid", "$450.00", "Credit Card"),
new("INV005", "Paid", "$550.00", "PayPal"),
new("INV006", "Pending", "$200.00", "Bank Transfer"),
new("INV007", "Unpaid", "$300.00", "Credit Card"),
];
}
| Invoice | Status | Method | Amount |
|---|---|---|---|
| INV001 | Paid | Credit Card | $250.00 |
| INV002 | Pending | PayPal | $150.00 |
| INV003 | Unpaid | Bank Transfer | $350.00 |
| INV004 | Paid | Credit Card | $450.00 |
| INV005 | Paid | PayPal | $550.00 |
| INV006 | Pending | Bank Transfer | $200.00 |
| INV007 | Unpaid | Credit Card | $300.00 |
| Total | $2,500.00 | ||
Installation
Usage
<Table>
<TableCaption>A list of your recent invoices.</TableCaption>
<TableHeader>
<TableRow>
<TableHead Class="w-[100px]">Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead>Method</TableHead>
<TableHead Class="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell Class="font-medium">INV001</TableCell>
<TableCell>Paid</TableCell>
<TableCell>Credit Card</TableCell>
<TableCell Class="text-right">$250.00</TableCell>
</TableRow>
</TableBody>
</Table>Composition
Use the following composition to build a Table:
Table
├── TableCaption
├── TableHeader
│ └── TableRow
│ ├── TableHead
│ ├── TableHead
│ ├── TableHead
│ └── TableHead
├── TableBody
│ ├── TableRow
│ │ ├── TableCell
│ │ ├── TableCell
│ │ ├── TableCell
│ │ └── TableCell
│ └── TableRow
│ ├── TableCell
│ ├── TableCell
│ ├── TableCell
│ └── TableCell
└── TableFooterFooter
Use the <TableFooter /> component to add a footer to the table.
<Table>
<TableCaption>A list of your recent invoices.</TableCaption>
<TableHeader>
<TableRow>
<TableHead Class="w-[100px]">Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead>Method</TableHead>
<TableHead Class="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
@foreach (var invoice in Invoices.Take(3))
{
<TableRow @key="invoice.Id">
<TableCell Class="font-medium">@invoice.Id</TableCell>
<TableCell>@invoice.PaymentStatus</TableCell>
<TableCell>@invoice.PaymentMethod</TableCell>
<TableCell Class="text-right">@invoice.TotalAmount</TableCell>
</TableRow>
}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colspan="3">Total</TableCell>
<TableCell Class="text-right">$2,500.00</TableCell>
</TableRow>
</TableFooter>
</Table>
@code {
private sealed record Invoice(string Id, string PaymentStatus, string TotalAmount, string PaymentMethod);
private static readonly Invoice[] Invoices =
[
new("INV001", "Paid", "$250.00", "Credit Card"),
new("INV002", "Pending", "$150.00", "PayPal"),
new("INV003", "Unpaid", "$350.00", "Bank Transfer"),
new("INV004", "Paid", "$450.00", "Credit Card"),
new("INV005", "Paid", "$550.00", "PayPal"),
new("INV006", "Pending", "$200.00", "Bank Transfer"),
new("INV007", "Unpaid", "$300.00", "Credit Card"),
];
}
| Invoice | Status | Method | Amount |
|---|---|---|---|
| INV001 | Paid | Credit Card | $250.00 |
| INV002 | Pending | PayPal | $150.00 |
| INV003 | Unpaid | Bank Transfer | $350.00 |
| Total | $2,500.00 | ||
Actions
A table showing actions for each row using a <DropdownMenu /> component.
<Table>
<TableHeader>
<TableRow>
<TableHead>Product</TableHead>
<TableHead>Price</TableHead>
<TableHead Class="text-right">Actions</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell Class="font-medium">Wireless Mouse</TableCell>
<TableCell>$29.99</TableCell>
<TableCell Class="text-right">
<DropdownMenu>
<DropdownMenuTrigger>
<Render>
<Button @attributes="context.Attributes" Variant="ButtonVariant.Ghost" Size="ButtonSize.Icon" Class="size-8">
<Icon Data="LucideIcons.MoreHorizontal" />
<span class="sr-only">Open menu</span>
</Button>
</Render>
</DropdownMenuTrigger>
<DropdownMenuContent Align="Align.End">
<DropdownMenuItem>Edit</DropdownMenuItem>
<DropdownMenuItem>Duplicate</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem Destructive="true">Delete</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</TableCell>
</TableRow>
<TableRow>
<TableCell Class="font-medium">Mechanical Keyboard</TableCell>
<TableCell>$129.99</TableCell>
<TableCell Class="text-right">
<DropdownMenu>
<DropdownMenuTrigger>
<Render>
<Button @attributes="context.Attributes" Variant="ButtonVariant.Ghost" Size="ButtonSize.Icon" Class="size-8">
<Icon Data="LucideIcons.MoreHorizontal" />
<span class="sr-only">Open menu</span>
</Button>
</Render>
</DropdownMenuTrigger>
<DropdownMenuContent Align="Align.End">
<DropdownMenuItem>Edit</DropdownMenuItem>
<DropdownMenuItem>Duplicate</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem Destructive="true">Delete</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</TableCell>
</TableRow>
<TableRow>
<TableCell Class="font-medium">USB-C Hub</TableCell>
<TableCell>$49.99</TableCell>
<TableCell Class="text-right">
<DropdownMenu>
<DropdownMenuTrigger>
<Render>
<Button @attributes="context.Attributes" Variant="ButtonVariant.Ghost" Size="ButtonSize.Icon" Class="size-8">
<Icon Data="LucideIcons.MoreHorizontal" />
<span class="sr-only">Open menu</span>
</Button>
</Render>
</DropdownMenuTrigger>
<DropdownMenuContent Align="Align.End">
<DropdownMenuItem>Edit</DropdownMenuItem>
<DropdownMenuItem>Duplicate</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem Destructive="true">Delete</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</TableCell>
</TableRow>
</TableBody>
</Table>
| Product | Price | Actions |
|---|---|---|
| Wireless Mouse | $29.99 | |
| Mechanical Keyboard | $129.99 | |
| USB-C Hub | $49.99 |
Data Table
You can use the <Table /> component to build more complex data tables. Sort, filter and page the rows in C# and render them with the same components.
RTL
To enable RTL support in Blazix, see the RTL configuration guide.
<Table>
<TableCaption>@T.Caption</TableCaption>
<TableHeader>
<TableRow>
<TableHead Class="w-[100px]">@T.Invoice</TableHead>
<TableHead>@T.Status</TableHead>
<TableHead>@T.Method</TableHead>
<TableHead Class="text-end">@T.Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
@foreach (var (invoice, status, amount, method) in Invoices)
{
<TableRow>
<TableCell Class="font-medium">@invoice</TableCell>
<TableCell>@T.Words[status]</TableCell>
<TableCell>@T.Words[method]</TableCell>
<TableCell Class="text-end">@amount</TableCell>
</TableRow>
}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colspan="3">@T.Total</TableCell>
<TableCell Class="text-end">$2,500.00</TableCell>
</TableRow>
</TableFooter>
</Table>
@code {
[CascadingParameter] private Language Language { get; set; } = Language.Arabic;
private static readonly (string Invoice, string Status, string Amount, string Method)[] Invoices =
[
("INV001", "paid", "$250.00", "credit-card"),
("INV002", "pending", "$150.00", "paypal"),
("INV003", "unpaid", "$350.00", "bank-transfer"),
("INV004", "paid", "$450.00", "credit-card"),
("INV005", "paid", "$550.00", "paypal"),
("INV006", "pending", "$200.00", "bank-transfer"),
("INV007", "unpaid", "$300.00", "credit-card"),
];
private Text T => Texts[Language];
private static readonly Translations<Text> Texts = new(
En: new("A list of your recent invoices.", "Invoice", "Status", "Method", "Amount", "Total", new()
{
["paid"] = "Paid", ["pending"] = "Pending", ["unpaid"] = "Unpaid",
["credit-card"] = "Credit Card", ["paypal"] = "PayPal", ["bank-transfer"] = "Bank Transfer",
}),
Ar: new("قائمة بفواتيرك الأخيرة.", "الفاتورة", "الحالة", "الطريقة", "المبلغ", "المجموع", new()
{
["paid"] = "مدفوع", ["pending"] = "قيد الانتظار", ["unpaid"] = "غير مدفوع",
["credit-card"] = "بطاقة ائتمانية", ["paypal"] = "PayPal", ["bank-transfer"] = "تحويل بنكي",
}),
He: new("רשימת החשבוניות האחרונות שלך.", "חשבונית", "סטטוס", "שיטה", "סכום", "סה\"כ", new()
{
["paid"] = "שולם", ["pending"] = "ממתין", ["unpaid"] = "לא שולם",
["credit-card"] = "כרטיס אשראי", ["paypal"] = "PayPal", ["bank-transfer"] = "העברה בנקאית",
}));
private sealed record Text(string Caption, string Invoice, string Status, string Method, string Amount, string Total,
Dictionary<string, string> Words);
}
Translated with AI for the demo, so it may have mistakes.
| الفاتورة | الحالة | الطريقة | المبلغ |
|---|---|---|---|
| INV001 | مدفوع | بطاقة ائتمانية | $250.00 |
| INV002 | قيد الانتظار | PayPal | $150.00 |
| INV003 | غير مدفوع | تحويل بنكي | $350.00 |
| INV004 | مدفوع | بطاقة ائتمانية | $450.00 |
| INV005 | مدفوع | PayPal | $550.00 |
| INV006 | قيد الانتظار | تحويل بنكي | $200.00 |
| INV007 | غير مدفوع | بطاقة ائتمانية | $300.00 |
| المجموع | $2,500.00 | ||