Files
basecoat/docs/src/components/table.mdx
T

154 lines
3.1 KiB
Plaintext
Raw Normal View History

2026-06-17 11:19:31 +08:00
# Table
2025-04-25 16:42:10 +08:00
2026-06-17 11:19:31 +08:00
<Preview class="w-full">
<div class="table-container">
2025-06-13 14:14:38 +08:00
<table class="table">
2025-04-25 16:42:10 +08:00
<caption>A list of your recent invoices.</caption>
<thead>
<tr>
<th>Invoice</th>
<th>Status</th>
<th>Method</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td class="font-medium">INV001</td>
<td>Paid</td>
<td>Credit Card</td>
<td class="text-end">$250.00</td>
2025-04-25 16:42:10 +08:00
</tr>
<tr>
<td class="font-medium">INV002</td>
<td>Pending</td>
<td>PayPal</td>
<td class="text-end">$150.00</td>
2025-04-25 16:42:10 +08:00
</tr>
<tr>
<td class="font-medium">INV003</td>
<td>Unpaid</td>
<td>Bank Transfer</td>
<td class="text-end">$350.00</td>
2025-04-25 16:42:10 +08:00
</tr>
<tr>
<td class="font-medium">INV004</td>
<td>Paid</td>
<td>Paypal</td>
<td class="text-end">$450.00</td>
2025-04-25 16:42:10 +08:00
</tr>
<tr>
<td class="font-medium">INV005</td>
<td>Paid</td>
<td>Credit Card</td>
<td class="text-end">$550.00</td>
2025-04-25 16:42:10 +08:00
</tr>
<tr>
<td class="font-medium">INV006</td>
<td>Pending</td>
<td>Bank Transfer</td>
<td class="text-end">$200.00</td>
2025-04-25 16:42:10 +08:00
</tr>
<tr>
<td class="font-medium">INV007</td>
<td>Unpaid</td>
<td>Credit Card</td>
<td class="text-end">$300.00</td>
2025-04-25 16:42:10 +08:00
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3">Total</td>
<td class="text-end">$2,500.00</td>
2025-04-25 16:42:10 +08:00
</tr>
</tfoot>
2025-06-13 14:14:38 +08:00
</table>
2026-06-17 11:19:31 +08:00
</div>
</Preview>
2025-04-25 16:42:10 +08:00
2026-06-17 11:19:31 +08:00
## Usage
2025-04-25 16:42:10 +08:00
2026-06-20 13:58:42 +08:00
Add `class="table"` to your table element. Wrap it in `class="table-container"` when horizontal scrolling is needed.
2025-04-25 16:42:10 +08:00
2026-06-17 11:19:31 +08:00
```html
<div class="table-container">
<table class="table">
2025-04-25 16:42:10 +08:00
<!-- Content of your table -->
</table>
2026-06-17 11:19:31 +08:00
</div>
```
2026-06-17 11:19:31 +08:00
## Examples
2026-06-17 11:19:31 +08:00
### Footer
2026-06-17 11:19:31 +08:00
<Preview class="w-full">
<table class="table">
<thead>
<tr>
<th>Invoice</th>
<th class="text-end">Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>INV001</td>
<td class="text-end">$250.00</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Total</td>
<td class="text-end">$250.00</td>
</tr>
</tfoot>
2026-06-17 11:19:31 +08:00
</table>
</Preview>
2026-06-17 11:19:31 +08:00
### Actions
2026-06-17 11:19:31 +08:00
<Preview class="w-full">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
<tr>
<td class="font-medium">Project Alpha</td>
<td class="text-end">
2026-06-20 13:58:42 +08:00
<button type="button" class="btn" data-variant="outline" data-size="xs">Open</button>
</td>
</tr>
</tbody>
2026-06-17 11:19:31 +08:00
</table>
</Preview>
2026-06-17 11:19:31 +08:00
### RTL
2026-06-17 11:19:31 +08:00
Set `dir="rtl"` on the table container when needed. Use logical alignment utilities such as `text-end`.
2026-06-17 11:19:31 +08:00
<Preview class="w-full">
<div class="table-container" dir="rtl">
<table class="table">
<caption>قائمة الفواتير الأخيرة.</caption>
<thead>
<tr>
<th>الفاتورة</th>
<th>الحالة</th>
<th class="text-end">المبلغ</th>
</tr>
</thead>
<tbody>
<tr>
<td class="font-medium">INV001</td>
<td>مدفوعة</td>
<td class="text-end">$250.00</td>
</tr>
</tbody>
</table>
2026-06-17 11:19:31 +08:00
</div>
</Preview>