DataGrid
Enhanced table with sorting, filtering, and pagination
Start Here
Start from the smallest working snippet, then move to interactive examples and the full API contract below.
Styled quick start
Copy this entrypoint first. It includes the imports required to get the component on screen.
<script lang="ts">
import '@dryui/ui/themes/default.css';
import '@dryui/ui/themes/dark.css';
import { DataGrid } from '@dryui/ui';
</script>
<DataGrid.Root>
<DataGrid.Table>...</DataGrid.Table>
<DataGrid.Header>...</DataGrid.Header>
<DataGrid.Column>...</DataGrid.Column>
<DataGrid.Body>...</DataGrid.Body>
<DataGrid.Row>...</DataGrid.Row>
<DataGrid.Cell>...</DataGrid.Cell>
<DataGrid.Pagination>...</DataGrid.Pagination>
<DataGrid.SelectAll>...</DataGrid.SelectAll>
<DataGrid.SelectCell>...</DataGrid.SelectCell>
<DataGrid.ExpandableRow>...</DataGrid.ExpandableRow>
<DataGrid.ExpandTrigger>...</DataGrid.ExpandTrigger>
</DataGrid.Root>Import options
Root package
import { DataGrid } from '@dryui/ui'Per-component subpath
import { DataGrid } from '@dryui/ui/data-grid'Customize
Use the interactive examples to see common variants, states, and composition patterns before building your own.
Sortable Data Grid
| Status | |||
|---|---|---|---|
| Alice Johnson | Engineering | $95,000 | Active |
| Bob Smith | Design | $82,000 | Active |
| Carol White | Marketing | $78,000 | Inactive |
| David Lee | Engineering | $105,000 | Active |
| Eva Chen | Product | $98,000 | Active |
<DataGrid.Root items={employees} pageSize={5} striped>
<DataGrid.Table>
<DataGrid.Header>
<DataGrid.Row>
<DataGrid.Column key="name" sortable>Name</DataGrid.Column>
<DataGrid.Column key="department" sortable filterable>Department</DataGrid.Column>
<DataGrid.Column key="salary" sortable>Salary</DataGrid.Column>
<DataGrid.Column key="status">Status</DataGrid.Column>
</DataGrid.Row>
</DataGrid.Header>
<DataGrid.Body>
{#snippet children({ items })}
{#each items as row (row.id)}
<DataGrid.Row>
<DataGrid.Cell>{row.name}</DataGrid.Cell>
<DataGrid.Cell>{row.department}</DataGrid.Cell>
<DataGrid.Cell>${row.salary.toLocaleString()}</DataGrid.Cell>
<DataGrid.Cell>{row.status}</DataGrid.Cell>
</DataGrid.Row>
{/each}
{/snippet}
</DataGrid.Body>
</DataGrid.Table>
<DataGrid.Pagination>
{#snippet children({ page, totalPages, canPrevious, canNext, previous, next })}
<Stack direction="horizontal" gap="sm" align="center" class="pagination-controls">
<Button variant="outline" size="sm" onclick={previous} disabled={!canPrevious}>Prev</Button>
<span>{page} / {totalPages}</span>
<Button variant="outline" size="sm" onclick={next} disabled={!canNext}>Next</Button>
</Stack>
{/snippet}
</DataGrid.Pagination>
</DataGrid.Root>Structure
Compound components always start with DataGrid.Root. Use this structure block to understand required wrappers before you wire state or styling.
DataGrid.Root DataGrid.Table DataGrid.Header DataGrid.Column DataGrid.Body DataGrid.Row DataGrid.Cell DataGrid.Pagination DataGrid.SelectAll DataGrid.SelectCell DataGrid.ExpandableRow DataGrid.ExpandTrigger
Compose
The full API contract lives here: props, CSS variables, and the public data attributes you can target when styling.
Compound component. Start with DataGrid.Root, then add only the parts you need.
DataGrid.Root
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
items | T[] | — | ✓ | — |
pageSize | number | — | — | — |
striped | boolean | false | — | — |
selectable | boolean | — | — | — |
onSelectionChange | (selected: string[]) => void | — | — | — |
actionBar | Snippet<[{ selectedCount: number; clearSelection: () => void }]> | — | — | — |
children | Snippet | — | ✓ | — |
Forwards <div> attributes via rest props. Common examples: id, style, role.
DataGrid.Table
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
children | Snippet | — | ✓ | — |
Forwards <table> attributes via rest props. Common examples: id, style, aria-describedby.
DataGrid.Header
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
children | Snippet | — | ✓ | — |
Forwards <tbody> attributes via rest props. Common examples: id, style, aria-describedby.
DataGrid.Column
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
key | string | — | ✓ | — |
sortable | boolean | — | — | — |
filterable | boolean | — | — | — |
pinned | boolean | — | — | — |
resizable | boolean | — | — | — |
header | Snippet | — | — | — |
children | Snippet | — | ✓ | — |
Forwards <td> attributes via rest props. Common examples: colspan, rowspan, headers.
DataGrid.Body
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
children | Snippet<[{ items: T[]; page: number }]> | — | ✓ | — |
Forwards <tbody> attributes via rest props. Common examples: id, style, aria-describedby. Omitted: children.
DataGrid.Row
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
rowId | string | — | — | — |
children | Snippet | — | ✓ | — |
Forwards <tr> attributes via rest props. Common examples: id, aria-selected, role.
DataGrid.Cell
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
children | Snippet | — | ✓ | — |
Forwards <td> attributes via rest props. Common examples: colspan, rowspan, headers.
DataGrid.Pagination
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
children | Snippet<[{ | — | — | — |
page | number | — | ✓ | — |
totalPages | number | — | ✓ | — |
totalItems | number | — | ✓ | — |
pageSize | number | — | ✓ | — |
canPrevious | boolean | — | ✓ | — |
canNext | boolean | — | ✓ | — |
previous | () => void | — | ✓ | — |
next | () => void | — | ✓ | — |
goto | (page: number) => void | — | ✓ | — |
Forwards <element> attributes via rest props. Common examples: id, class, aria-label. Omitted: children.
DataGrid.SelectAll
| Prop | Type | Default | Required | Bindable |
|---|
Forwards <td> attributes via rest props. Common examples: colspan, rowspan, headers.
DataGrid.SelectCell
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
rowId | string | — | ✓ | — |
Forwards <td> attributes via rest props. Common examples: colspan, rowspan, headers.
DataGrid.ExpandableRow
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
rowId | string | — | ✓ | — |
expandable | Snippet | — | ✓ | — |
children | Snippet | — | ✓ | — |
Forwards <tr> attributes via rest props. Common examples: id, aria-selected, role.
DataGrid.ExpandTrigger
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
rowId | string | — | ✓ | — |
children | Snippet | — | — | — |
Forwards native HTML attributes via rest props.