nili/ui
كل المكوّنات

Table

عرض شامل
٢٩ تصدير١٢ محور تنويع٣١ خاصيّة٤ ملف
import { SortDirection, Table, TableAlign, TableBody, TableCell, TableFooter } from '@nili/ui';

هذه صفحة العرض الشامل الخاصة بالمكتبة، معروضة حيّة. غيّر اللغة أو السمة من الأعلى وسَتتبعك.

أساسي

عنصر جدول حقيقي، لا عناصر div بأدوار صفوف. فقارئات الشاشة تمنح الجدول الحقيقي وضع تنقّل — الانتقال خلية خلية وسماع ترويسة العمود مع كل قفزة — ولا ينجو شيء من ذلك في إعادة الكتابة. وlabel يسمّيه؛ فجدول بلا اسم يُعلَن بوصفه «جدول» لا أكثر.

العميلالمبلغالحالة
Acme Co.1,200مدفوعة
Globex480معلّقة
Initech3,150متأخّرة
Umbrella90مدفوعة
import {
  Table, TableHeader, TableBody, TableRow, TableHead, TableCell, Badge,
} from "@nili/ui"

export function Example() {
  return (
    <Table label="Invoices">
      <TableHeader>
        <TableRow>
          <TableHead>Customer</TableHead>
          <TableHead align="end">Amount</TableHead>
          <TableHead>Status</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        {rows.map((row) => (
          <TableRow key={row.id}>
            <TableCell header>{row.customer}</TableCell>
            <TableCell align="end" numeric>{row.amount}</TableCell>
            <TableCell>
              <Badge appearance="light" color="green" dot>Paid</Badge>
            </TableCell>
          </TableRow>
        ))}
      </TableBody>
    </Table>
  )
}

ارتفاع الصف والتعليق

ارتفاعان للصف — X-Large (‏٦٤) وLarge (‏٤٨). ويسمّي caption الظاهر الجدولَ، فلا حاجة إلى label أيضًا.

size=lg، مع تعليق
Invoices from the last 30 days
العميلالمبلغ
Acme Co.1,200
Globex480
Initech3,150
import { Table } from "@nili/ui"

export function Example() {
  return (
    <>
      <Table size="xl" label="Invoices">…</Table>
      <Table size="lg" caption={t('sizes.caption')}>…</Table>
    </>
  )
}

أولوية الخلية

مدى علوّ صوت العمود. فـleading هوية الصف، وpassive بيانات وصفية يتجاوزها البصر، وnone يُسقط تنسيق الخط كليًا كي تستضيف الخلية عنصر تحكّم.

العميلالبريدآخر تحديثالإجراءات
A
Acme Co.
billing@acme.comقبل يومين
G
Globex
ap@globex.ioقبل يومين
I
Initech
finance@initech.devقبل يومين
import { Table, TableCell } from "@nili/ui"

export function Example() {
  return (
    <TableRow>
      <TableCell priority="leading" header>Acme Co.</TableCell>
      <TableCell priority="regular">billing@acme.com</TableCell>
      <TableCell priority="passive">Updated 2 days ago</TableCell>
      <TableCell priority="none">
        <CompactButton aria-label="More"><Icon icon={RiMore2Fill} /></CompactButton>
      </TableCell>
    </TableRow>
  )
}

الفرز

يرسم sortable زرّ الفرز ويدير aria-sort على الخلية. ويقع على العمود المفروز فقط — فـ«none» على كل عمود آخر ضجيج يقرأه قارئ الشاشة بصوت عالٍ.

Initech3,150
Acme Co.1,200
Globex480
Umbrella90
import { TableHead } from "@nili/ui"

export function Example() {
  const [sort, setSort] = useState({ key: "amount", direction: "desc" })

  return (
    <TableHead
      align="end"
      sortable
      sortDirection={sort.key === "amount" ? sort.direction : null}
      sortLabel={t('sorting.byAmount')}
      onSort={(direction) => setSort({ key: "amount", direction })}
    >
      Amount
    </TableHead>
  )
}

التحديد والترويسة الملتصقة والتذييل

يبرز selected صفًّا ويضيف aria-selected. أما interactive فمجرّد دلالة تحويم — فصفٌّ يفتح سجلًّا بـonClick غير مرئي لقارئ الشاشة، لذا ضع رابطًا أو زرًّا حقيقيًا في خلية ودع إبراز الصف يتبعه.

العميلالمبلغ
Acme Co.1,200
Globex480
Initech3,150
Umbrella90
تم تحديد 1 من 44,920
import { Table, TableRow, TableHead, TableCell, Checkbox } from "@nili/ui"

export function Example() {
  return (
    <Table label="Invoices" stickyHeader>
      <TableHeader sticky>
        <TableRow>
          <TableHead state="empty"><Checkbox aria-label="Select all" /></TableHead>
          <TableHead>Customer</TableHead>
        </TableRow>
      </TableHeader>

      <TableBody>
        <TableRow selected interactive>
          <TableCell priority="none"><Checkbox aria-label="Select row" checked /></TableCell>
          <TableCell header>Globex</TableCell>
        </TableRow>
      </TableBody>

      <TableFooter>
        <TableRow>
          <TableCell colSpan={2}>4 invoices</TableCell>
        </TableRow>
      </TableFooter>
    </Table>
  )
}