عرض البيانات
table
غلاف متجاوب لجداول البيانات.
| الفاتورة | الحالة | المبلغ |
|---|---|---|
| INV-001 | مدفوعة | $250.00 |
| INV-002 | قيد الانتظار | $150.00 |
<x-ui.table class="w-full max-w-lg">
<thead>
<tr class="border-b text-start">
<th class="h-10 px-2 font-medium text-muted-foreground">الفاتورة</th>
<th class="h-10 px-2 font-medium text-muted-foreground">الحالة</th>
<th class="h-10 px-2 text-end font-medium text-muted-foreground">
المبلغ
</th>
</tr>
</thead>
<tbody>
<tr class="border-b">
<td class="p-2 font-medium">INV-001</td>
<td class="p-2">مدفوعة</td>
<td class="p-2 text-end">$250.00</td>
</tr>
<tr>
<td class="p-2 font-medium">INV-002</td>
<td class="p-2">قيد الانتظار</td>
<td class="p-2 text-end">$150.00</td>
</tr>
</tbody>
</x-ui.table>
التثبيت
php artisan ui:add table
1. ثبّت الاعتماديات
- composer:
gehrisandro/tailwind-merge-laravel
2.
انسخ الكود إلى
resources/views/components/ui/
resources/views/components/ui/table.blade.php
@props([])
@php
$classes = \TailwindMerge\Laravel\Facades\TailwindMerge::merge(
'w-full caption-bottom text-sm',
$attributes->get('class'),
);
@endphp
<div class="relative w-full overflow-x-auto">
<table {{ $attributes->except('class')->merge(['class' => $classes]) }}>
{{ $slot }}
</table>
</div>
الاستخدام
<x-ui.table>
<thead>
<tr class="border-b text-start">
<th class="h-10 px-2 font-medium text-muted-foreground">Invoice</th>
<th class="h-10 px-2 font-medium text-muted-foreground">Status</th>
</tr>
</thead>
<tbody>
<tr class="border-b">
<td class="p-2 font-medium">INV-001</td>
<td class="p-2">Paid</td>
</tr>
</tbody>
</x-ui.table>
غلّف عناصر thead/tbody/tr/th/td العادية؛ والتنسيق عبر محددات أدوات Tailwind في ترميزك.
الخصائص
كل خاصية مع قيمتها الافتراضية. مرّر أيًّا منها كسمة، واستخدم : لربط قيمة PHP.
@props([])