İçeriğe geç
BigBang

Sık açılanlar

    ↑↓Gezin↵AçEscKapat
    EN

    Bileşenler

    DataTable

    Sıralama, seçim, sütun görünürlüğü ve sanallaştırma ile büyük ve değişen verileri tabloda gösterir.

    Storybook
    Storybook
    Kaynak kod
    Kaynak kod

    Aşağıdaki örnek Storybook’tan canlı yüklenir; denetimleri Storybook’ta açabilirsiniz.

    Canlı örnek, StorybookStorybook'ta aç

    DataTable dört şey ister: sütun tanımları (columns), veri (data), her satır için kararlı bir kimlik (getRowId) ve bir başlık (caption). Görünüm, Table ile aynı parçalardan gelir.

    Öğe listesi
    Durum
    Öğe 1EtkinKullanıcı 112
    Öğe 2BeklemedeKullanıcı 249
    Öğe 3TaslakKullanıcı 386
    Öğe 4TamamlandıKullanıcı 4123
    Öğe 5BaşarısızKullanıcı 5160
    import { createDataTableColumnHelper, DataTable, StatusBadge, type StatusKey } from '@bigbang/ui';
    type Row = { id: string; name: string; status: StatusKey; owner: string; count: number };
    const data: Row[] = [
    { id: 'row-1', name: 'Öğe 1', status: 'active', owner: 'Kullanıcı 1', count: 12 },
    { id: 'row-2', name: 'Öğe 2', status: 'pending', owner: 'Kullanıcı 2', count: 49 },
    { id: 'row-3', name: 'Öğe 3', status: 'draft', owner: 'Kullanıcı 3', count: 86 },
    { id: 'row-4', name: 'Öğe 4', status: 'completed', owner: 'Kullanıcı 4', count: 123 },
    { id: 'row-5', name: 'Öğe 5', status: 'failed', owner: 'Kullanıcı 5', count: 160 },
    ];
    const helper = createDataTableColumnHelper<Row>();
    const columns = [
    helper.accessor('name', { header: 'Ad', meta: { rowHeader: true } }),
    helper.accessor('status', { header: 'Durum', enableSorting: false, cell: (context) => <StatusBadge status={context.getValue()} /> }),
    helper.accessor('owner', { header: 'Sahibi' }),
    helper.accessor('count', { header: 'Adet', meta: { numeric: true } }),
    ];
    export default function Default() {
    return <DataTable columns={columns} data={data} getRowId={(row) => row.id} caption="Öğe listesi" />;
    }

    Sıralanabilir sütunun başlığı bir butondur. Tıklayınca artan, azalan ve sıralamasız arasında döner; th üzerindeki aria-sort durumu bildirir ve değişiklik kibar bir canlı bölgede duyurulur. defaultSorting ilk sıralamayı verir; durumu siz yönetmek için sorting ve onSortingChange kullanın. Sunucuda sıralıyorsanız manualSorting ekleyin.

    Öğe listesi
    Durum
    Öğe 5BaşarısızKullanıcı 5160
    Öğe 4TamamlandıKullanıcı 4123
    Öğe 3TaslakKullanıcı 386
    Öğe 2BeklemedeKullanıcı 249
    Öğe 1EtkinKullanıcı 112
    import { createDataTableColumnHelper, DataTable, StatusBadge, type StatusKey } from '@bigbang/ui';
    type Row = { id: string; name: string; status: StatusKey; owner: string; count: number };
    const data: Row[] = [
    { id: 'row-1', name: 'Öğe 1', status: 'active', owner: 'Kullanıcı 1', count: 12 },
    { id: 'row-2', name: 'Öğe 2', status: 'pending', owner: 'Kullanıcı 2', count: 49 },
    { id: 'row-3', name: 'Öğe 3', status: 'draft', owner: 'Kullanıcı 3', count: 86 },
    { id: 'row-4', name: 'Öğe 4', status: 'completed', owner: 'Kullanıcı 4', count: 123 },
    { id: 'row-5', name: 'Öğe 5', status: 'failed', owner: 'Kullanıcı 5', count: 160 },
    ];
    const helper = createDataTableColumnHelper<Row>();
    const columns = [
    helper.accessor('name', { header: 'Ad', meta: { rowHeader: true } }),
    helper.accessor('status', { header: 'Durum', enableSorting: false, cell: (context) => <StatusBadge status={context.getValue()} /> }),
    helper.accessor('owner', { header: 'Sahibi' }),
    helper.accessor('count', { header: 'Adet', meta: { numeric: true } }),
    ];
    export default function Sorting() {
    return <DataTable columns={columns} data={data} getRowId={(row) => row.id} caption="Öğe listesi" defaultSorting={[{ id: 'count', desc: true }]} />;
    }

    selectionMode="multiple" bir onay kutusu sütunu ve tümünü seç kutusu ekler; bazı satırlar seçiliyken kutu karışık durumu gösterir. Satır onay kutuları, getRowLabel ile satırın adını taşır: “Öğe 1 satırını seç”. single bir seferde tek satıra izin verir.

    Öğe listesi
    Durum
    Öğe 1EtkinKullanıcı 112
    Öğe 2BeklemedeKullanıcı 249
    Öğe 3TaslakKullanıcı 386
    Öğe 4TamamlandıKullanıcı 4123
    Öğe 5BaşarısızKullanıcı 5160
    import { createDataTableColumnHelper, DataTable, StatusBadge, type StatusKey } from '@bigbang/ui';
    type Row = { id: string; name: string; status: StatusKey; owner: string; count: number };
    const data: Row[] = [
    { id: 'row-1', name: 'Öğe 1', status: 'active', owner: 'Kullanıcı 1', count: 12 },
    { id: 'row-2', name: 'Öğe 2', status: 'pending', owner: 'Kullanıcı 2', count: 49 },
    { id: 'row-3', name: 'Öğe 3', status: 'draft', owner: 'Kullanıcı 3', count: 86 },
    { id: 'row-4', name: 'Öğe 4', status: 'completed', owner: 'Kullanıcı 4', count: 123 },
    { id: 'row-5', name: 'Öğe 5', status: 'failed', owner: 'Kullanıcı 5', count: 160 },
    ];
    const helper = createDataTableColumnHelper<Row>();
    const columns = [
    helper.accessor('name', { header: 'Ad', meta: { rowHeader: true } }),
    helper.accessor('status', { header: 'Durum', enableSorting: false, cell: (context) => <StatusBadge status={context.getValue()} /> }),
    helper.accessor('owner', { header: 'Sahibi' }),
    helper.accessor('count', { header: 'Adet', meta: { numeric: true } }),
    ];
    export default function Selection() {
    return <DataTable columns={columns} data={data} getRowId={(row) => row.id} getRowLabel={(row) => row.name} caption="Öğe listesi" selectionMode="multiple" defaultRowSelection={{ 'row-2': true }} />;
    }

    columnToggle tablonun üstüne bir “Sütunlar” butonu ekler; düğme, her sütun için bir onay kutusu içeren bir panel açar. Başlangıç durumunu defaultColumnVisibility, kontrolü columnVisibility ve onColumnVisibilityChange verir.

    Öğe listesi
    Durum
    Öğe 1Etkin12
    Öğe 2Beklemede49
    Öğe 3Taslak86
    Öğe 4Tamamlandı123
    Öğe 5Başarısız160
    import { createDataTableColumnHelper, DataTable, StatusBadge, type StatusKey } from '@bigbang/ui';
    type Row = { id: string; name: string; status: StatusKey; owner: string; count: number };
    const data: Row[] = [
    { id: 'row-1', name: 'Öğe 1', status: 'active', owner: 'Kullanıcı 1', count: 12 },
    { id: 'row-2', name: 'Öğe 2', status: 'pending', owner: 'Kullanıcı 2', count: 49 },
    { id: 'row-3', name: 'Öğe 3', status: 'draft', owner: 'Kullanıcı 3', count: 86 },
    { id: 'row-4', name: 'Öğe 4', status: 'completed', owner: 'Kullanıcı 4', count: 123 },
    { id: 'row-5', name: 'Öğe 5', status: 'failed', owner: 'Kullanıcı 5', count: 160 },
    ];
    const helper = createDataTableColumnHelper<Row>();
    const columns = [
    helper.accessor('name', { header: 'Ad', meta: { rowHeader: true } }),
    helper.accessor('status', { header: 'Durum', enableSorting: false, cell: (context) => <StatusBadge status={context.getValue()} /> }),
    helper.accessor('owner', { header: 'Sahibi' }),
    helper.accessor('count', { header: 'Adet', meta: { numeric: true } }),
    ];
    export default function ColumnVisibility() {
    return <DataTable columns={columns} data={data} getRowId={(row) => row.id} caption="Öğe listesi" columnToggle defaultColumnVisibility={{ owner: false }} />;
    }

    status yükleniyor, boş, süzgece uymayan ve hata durumlarını yerleşik olarak gösterir; üst bilgi her zaman yerinde kalır. Yüklenirken tablo aria-busy olur ve iskelet satırlar gösterilir. Boş ve hata iletileri bir eylem butonu taşıyabilir.

    Öğe listesi: loading
    Durum
    Yükleniyor
    Öğe listesi: filtered
    Durum

    Filtrelere uyan kayıt yok

    Öğe listesi: error
    Durum
    import { createDataTableColumnHelper, DataTable, StatusBadge, type StatusKey } from '@bigbang/ui';
    type Row = { id: string; name: string; status: StatusKey; owner: string; count: number };
    const helper = createDataTableColumnHelper<Row>();
    const columns = [
    helper.accessor('name', { header: 'Ad', meta: { rowHeader: true } }),
    helper.accessor('status', { header: 'Durum', enableSorting: false, cell: (context) => <StatusBadge status={context.getValue()} /> }),
    helper.accessor('owner', { header: 'Sahibi' }),
    helper.accessor('count', { header: 'Adet', meta: { numeric: true } }),
    ];
    export default function States() {
    return (
    <div className="flex w-full flex-col gap-3xl">
    <DataTable columns={columns} data={[]} getRowId={(row) => row.id} caption="Öğe listesi: loading" status="loading" />
    <DataTable columns={columns} data={[]} getRowId={(row) => row.id} caption="Öğe listesi: filtered" status="filtered-empty" onClearFilters={() => {}} />
    <DataTable columns={columns} data={[]} getRowId={(row) => row.id} caption="Öğe listesi: error" status="error" onRetry={() => {}} />
    </div>
    );
    }

    rowActions son sütunda, satırın işlemlerini gösterir; her işlem ayrı bir sekme durağıdır ve adı satırı belirtmelidir. onRowOpen ilk sütunun içeriğini bir butona çevirir; böylece satır yalnızca tıklanır değil, klavyeyle de açılır.

    Öğe listesi
    Durumİşlemler
    EtkinKullanıcı 112
    BeklemedeKullanıcı 249
    TaslakKullanıcı 386
    TamamlandıKullanıcı 4123
    BaşarısızKullanıcı 5160
    import { createDataTableColumnHelper, DataTable, StatusBadge, type StatusKey, IconButton } from '@bigbang/ui';
    type Row = { id: string; name: string; status: StatusKey; owner: string; count: number };
    const data: Row[] = [
    { id: 'row-1', name: 'Öğe 1', status: 'active', owner: 'Kullanıcı 1', count: 12 },
    { id: 'row-2', name: 'Öğe 2', status: 'pending', owner: 'Kullanıcı 2', count: 49 },
    { id: 'row-3', name: 'Öğe 3', status: 'draft', owner: 'Kullanıcı 3', count: 86 },
    { id: 'row-4', name: 'Öğe 4', status: 'completed', owner: 'Kullanıcı 4', count: 123 },
    { id: 'row-5', name: 'Öğe 5', status: 'failed', owner: 'Kullanıcı 5', count: 160 },
    ];
    const helper = createDataTableColumnHelper<Row>();
    const columns = [
    helper.accessor('name', { header: 'Ad', meta: { rowHeader: true } }),
    helper.accessor('status', { header: 'Durum', enableSorting: false, cell: (context) => <StatusBadge status={context.getValue()} /> }),
    helper.accessor('owner', { header: 'Sahibi' }),
    helper.accessor('count', { header: 'Adet', meta: { numeric: true } }),
    ];
    export default function RowActions() {
    return (
    <DataTable
    columns={columns}
    data={data}
    getRowId={(row) => row.id}
    caption="Öğe listesi"
    onRowOpen={() => {}}
    rowActions={(row) => (
    <>
    <IconButton icon="pencil" size="sm" label={`Düzenle: ${row.name}`} />
    <IconButton icon="trash" size="sm" label={`Sil: ${row.name}`} />
    </>
    )}
    />
    );
    }

    footer tablonun altında bir satır açar. Sayfalama bileşeni oraya konur; DataTable sayfalamayı kendisi yapmaz. Veri bir sayfadan ibaretse totalRowCount ile toplam satırı bildirin.

    Öğe listesi
    Durum
    Öğe 1EtkinKullanıcı 112
    Öğe 2BeklemedeKullanıcı 249
    Sayfa 1 / 3
    import { createDataTableColumnHelper, DataTable, StatusBadge, type StatusKey, Button } from '@bigbang/ui';
    import { useState } from 'react';
    type Row = { id: string; name: string; status: StatusKey; owner: string; count: number };
    const data: Row[] = [
    { id: 'row-1', name: 'Öğe 1', status: 'active', owner: 'Kullanıcı 1', count: 12 },
    { id: 'row-2', name: 'Öğe 2', status: 'pending', owner: 'Kullanıcı 2', count: 49 },
    { id: 'row-3', name: 'Öğe 3', status: 'draft', owner: 'Kullanıcı 3', count: 86 },
    { id: 'row-4', name: 'Öğe 4', status: 'completed', owner: 'Kullanıcı 4', count: 123 },
    { id: 'row-5', name: 'Öğe 5', status: 'failed', owner: 'Kullanıcı 5', count: 160 },
    ];
    const helper = createDataTableColumnHelper<Row>();
    const columns = [
    helper.accessor('name', { header: 'Ad', meta: { rowHeader: true } }),
    helper.accessor('status', { header: 'Durum', enableSorting: false, cell: (context) => <StatusBadge status={context.getValue()} /> }),
    helper.accessor('owner', { header: 'Sahibi' }),
    helper.accessor('count', { header: 'Adet', meta: { numeric: true } }),
    ];
    export default function WithFooter() {
    const [page, setPage] = useState(0);
    const rows = data.slice(page * 2, page * 2 + 2);
    return (
    <DataTable
    columns={columns}
    data={rows}
    getRowId={(row) => row.id}
    caption="Öğe listesi"
    totalRowCount={data.length}
    footer={
    <>
    <span className="type-body-sm text-fg-subtle">Sayfa {page + 1} / 3</span>
    <span className="flex items-center gap-sm">
    <Button size="sm" variant="secondary" disabled={page === 0} onClick={() => setPage(page - 1)}>
    Önceki
    </Button>
    <Button size="sm" variant="secondary" disabled={page === 2} onClick={() => setPage(page + 1)}>
    Sonraki
    </Button>
    </span>
    </>
    }
    />
    );
    }

    virtualize yalnızca görünen satırları üretir. Sabit yükseklikli bir kaydırma kapsayıcısı ister (scrollClassName="max-h-96"); 5.000 satırlık örnek Storybook’ta çalışır.

    Canlı örnek, StorybookStorybook'ta aç

    Sütun tanımında meta: { pin: 'start' } ya da meta: { pin: 'end' } o sütunu yatay kaydırmada yerinde tutar. Satırı tanıtan ad sütununu başa, tutar gibi karşılaştırılan sütunu sona sabitleyin. Başa sabit bir sütun varsa seçim ve aç/kapat sütunları da sabitlenir; sabit alanın kenarında ince bir çizgi görünür.

    Canlı örnek, StorybookStorybook'ta aç

    renderExpanded her satırın başına bir aç/kapat düğmesi ekler ve açılan satırın altında tüm genişlikte bir ayrıntı satırı gösterir. Açılamayacak satırları getRowCanExpand ile ayırın; açık satırları expanded ve onExpandedChange ile yönetebilirsiniz.

    Canlı örnek, StorybookStorybook'ta aç

    DataTable renklerini Table ile aynı table.* token’larından alır; iki modda da aynı yapıda görünür.

    Öğe listesi
    Durum
    Öğe 1EtkinKullanıcı 112
    Öğe 2BeklemedeKullanıcı 249
    Öğe 3TaslakKullanıcı 386
    Öğe 4TamamlandıKullanıcı 4123
    Öğe 5BaşarısızKullanıcı 5160
    Öğe listesi
    Durum
    Öğe 1EtkinKullanıcı 112
    Öğe 2BeklemedeKullanıcı 249
    Öğe 3TaslakKullanıcı 386
    Öğe 4TamamlandıKullanıcı 4123
    Öğe 5BaşarısızKullanıcı 5160
    import { createDataTableColumnHelper, DataTable, StatusBadge, type StatusKey } from '@bigbang/ui';
    type Row = { id: string; name: string; status: StatusKey; owner: string; count: number };
    const data: Row[] = [
    { id: 'row-1', name: 'Öğe 1', status: 'active', owner: 'Kullanıcı 1', count: 12 },
    { id: 'row-2', name: 'Öğe 2', status: 'pending', owner: 'Kullanıcı 2', count: 49 },
    { id: 'row-3', name: 'Öğe 3', status: 'draft', owner: 'Kullanıcı 3', count: 86 },
    { id: 'row-4', name: 'Öğe 4', status: 'completed', owner: 'Kullanıcı 4', count: 123 },
    { id: 'row-5', name: 'Öğe 5', status: 'failed', owner: 'Kullanıcı 5', count: 160 },
    ];
    const helper = createDataTableColumnHelper<Row>();
    const columns = [
    helper.accessor('name', { header: 'Ad', meta: { rowHeader: true } }),
    helper.accessor('status', { header: 'Durum', enableSorting: false, cell: (context) => <StatusBadge status={context.getValue()} /> }),
    helper.accessor('owner', { header: 'Sahibi' }),
    helper.accessor('count', { header: 'Adet', meta: { numeric: true } }),
    ];
    export default function Default() {
    return <DataTable columns={columns} data={data} getRowId={(row) => row.id} caption="Öğe listesi" />;
    }