Table
Genel görünümimport { SortDirection, Table, TableAlign, TableBody, TableCell, TableFooter } from '@nili/ui';Bu, kütüphanenin kendi genel görünüm sayfası — canlı olarak render ediliyor. Üstten dili veya temayı değiştirin, o da değişir.
Temel
Satır rolü verilmiş div’ler değil, gerçek bir table öğesi. Ekran okuyucular gerçek bir tabloya gezinme kipi verir — hücre hücre ilerlemek, her sıçrayışta sütun başlığını duymak — ve yeniden yazımda bunların hiçbiri kalmaz. label onu adlandırır; adsız bir tablo yalnızca “tablo” diye duyurulur.
| Müşteri | Tutar | Durum |
|---|---|---|
| Acme Co. | 1,200 | ödendi |
| Globex | 480 | beklemede |
| Initech | 3,150 | gecikmiş |
| Umbrella | 90 | ödendi |
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>
)
}Satır yüksekliği ve başlık
İki satır yüksekliği — X-Large (64) ve Large (48). Görünür bir caption tabloyu adlandırır; ayrıca label gerekmez.
| Müşteri | Tutar |
|---|---|
| Acme Co. | 1,200 |
| Globex | 480 |
| Initech | 3,150 |
import { Table } from "@nili/ui"
export function Example() {
return (
<>
<Table size="xl" label="Invoices">…</Table>
<Table size="lg" caption={t('sizes.caption')}>…</Table>
</>
)
}Hücre önceliği
Bir sütunun ne kadar yüksek sesle okunduğu. leading satırın kimliğidir, passive gözün atlaması gereken üstveridir ve none hücrenin bir denetim barındırabilmesi için tipografi stilini tümüyle kaldırır.
| Müşteri | E‑posta | Güncellendi | Eylemler |
|---|---|---|---|
A | billing@acme.com | 2 gün önce | |
G | ap@globex.io | 2 gün önce | |
I | finance@initech.dev | 2 gün önce |
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>
)
}Sıralama
sortable sıralama düğmesini çizer ve hücredeki aria-sort’u yönetir. Yalnızca sıralanan sütuna iner — diğer her sütundaki “none”, ekran okuyucunun sesli okuduğu gürültüdür.
| Initech | 3,150 |
|---|---|
| Acme Co. | 1,200 |
| Globex | 480 |
| Umbrella | 90 |
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>
)
}Seçim, yapışkan başlık ve alt bilgi
selected bir satırı vurgular ve aria-selected ekler. interactive yalnızca bir üzerine gelme ipucudur — onClick’i bir kaydı açan bir satır ekran okuyucuya görünmez; bu yüzden hücreye gerçek bir bağlantı ya da düğme koyun ve satır vurgusu onu izlesin.
| Müşteri | Tutar | |
|---|---|---|
| Acme Co. | 1,200 | |
| Globex | 480 | |
| Initech | 3,150 | |
| Umbrella | 90 | |
| 4 öğeden 1 seçili | 4,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>
)
}Table
extends ComponentPropsWithoutRef<'table'>
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| size | xl | lg | xl | |
| label | string | — | Accessible name. A table with no name is announced as "table" and nothing else, which is useless on a page with three of them. |
| caption | ReactNode | — | Visible caption, rendered above the table. Also names it. |
| stickyHeader | boolean | false | Keeps the header visible while the body scrolls. |
| scrollable | boolean | true | Wrap in a scrollable, keyboard-focusable region. On by default: a table that overflows horizontally is unreachable by keyboard otherwise. |
| scrollClassName | string | — | Class for the scroll wrapper. Use `className` for the `<table>`. |
TableCaption
dahiliTableCell
extends Omit< ComponentPropsWithoutRef<'td'>, 'align' >
Varyant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| align | start | center | end | start | |
| priority | leading | regular | passive | none | regular | Figma's `Priority` — how loudly the column reads. `leading` is the row's identity, `passive` is metadata the eye should skip, `none` drops the type styling so the cell can host a control. |
| numeric | boolean | false | Tabular figures, so a column of numbers lines up. |
| size | xl | lg | xl |
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| header | boolean | false | Makes the cell a row header (`<th scope="row">`). The first column of a data table usually is one, and marking it lets a screen reader say which row it is reading. |
TableHead
extends Omit< ComponentPropsWithoutRef<'th'>, 'align' >
Varyant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| align | start | center | end | start | |
| state | default | disabled | empty | default | Figma's header `State`. `empty` marks a header with no label — the checkbox column — so it is not announced as naming its column. |
| size | xl | lg | xl |
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| sortable | boolean | false | Renders a sort button and manages `aria-sort` on the cell. |
| sortDirection | desc | asc | — | Current direction, or `null` when this column is not the sort key. |
| onSort | (direction: SortDirection) => void | — | |
| sortLabel | string | — | Accessible name for the sort button, e.g. `` (c) => `Sort by ${c}` ``. |
TableHeader
Varyant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| sticky | 'true' | 'false' | false |
TableRow
extends ComponentPropsWithoutRef<'tr'>
Varyant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| selected | boolean | false | Highlights the row and adds `aria-selected`. |
| interactive | boolean | false | Hover affordance for a row that navigates. The click target must still be a real control *inside* the row — see the note in the component. |
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — |
TableScroll
dahiliTableSortButton
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| align | start | center | end | start | |
| sorted | 'true' | 'false' | false |