Carregando…
Carregando…
Carregando…Feature-rich table with sorting, filtering, pagination, selection, sticky header and grid/list/tree modes.
$ npx kikitocn add table@/lib/utilsimport { DataTable } from "@/components/ui/cn/table/DataTable";
export function DataTableExample() {
return (
<DataTable />
);
}| Prop | Tipo | Padrão | Descrição |
|---|---|---|---|
variant | 'table' | 'grid' | 'list' | 'tree' | 'table' | Seleciona o renderizador: 'table' (completo), 'grid' (DataGrid leve), 'list' (definition list/cards) ou 'tree' (linhas hierárquicas) |
rows | T[] | TreeTableRow<T>[] | undefined | Registros das variantes 'grid' e 'tree' (substitui `data` nessas variantes) |
items | DataListItem[] | undefined | variant='list': itens { label, value, span? } |
layout | 'horizontal' | 'vertical' | 'grid' | 'horizontal' | variant='list': disposição dos itens |
defaultExpanded | boolean | false | variant='tree': expande todas as linhas por padrão |
columns* | ColumnDef<TRow>[] | — | Definição das colunas: { key, header, cell?, sortable?, filterable?, align?, ... } |
data* | TRow[] | — | Array de registros a exibir |
selectable | boolean | false | Habilita checkboxes de seleção por linha |
defaultPageSize | number | 10 | Número de linhas por página inicial |
pageSizeOptions | number[] | [10, 25, 50] | Opções de tamanho de página |
stickyHeader | boolean | false | Fixa o cabeçalho ao rolar |
striped | boolean | false | Alterna cor de fundo nas linhas |
size | 'sm' | 'md' | 'lg' | 'md' | Densidade das linhas |
loading | boolean | false | Exibe estado de carregamento |
emptyMessage | string | undefined | Mensagem quando não há dados |
onRowClick | (row: TRow) => void | undefined | Callback ao clicar em uma linha |
DataTable — filters, sort, bulk actions, pagination
| Name | Role | Status | Joined | |
|---|---|---|---|---|
| Alice Chen | Developer | Active | 2023-01-15 | |
| Bob Tanaka | Designer | Active | 2023-03-22 | |
| Carol Wright | Developer | Inactive | 2022-11-08 | |
| Dan Müller | Designer | Active | 2024-02-01 |
Sortable + selectable + striped
| Status | ||||
|---|---|---|---|---|
| Alice Chen | Engineer | Active | 98 | |
| Bob Tanaka | Designer | Active | 87 | |
| Carol Davis | PM | Away | 92 | |
| David Kim | Engineer | Inactive | 74 | |
| Eva Rodriguez | Designer | Active | 95 |
Horizontal
Grid + bordered + striped
Tree Table — expandable hierarchy with toggle controls
| Name | Type | Size |
|---|---|---|
| src | folder | — |
| public | folder | — |
| package.json | file | 1.6 KB |