> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pharen.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Data grid

> Import and use the Data grid components from @pharen/ui.

export const PharenUiPreview = ({name, title = 'Pharen UI component preview'}) => <div className="not-prose my-6 overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm dark:border-white/10 dark:bg-zinc-950">
    <div className="pharen-ui-preview-root" data-pharen-ui-preview data-example={name} role="region" aria-label={title} />
  </div>;

Use **Data grid** to build sortable, filterable, and paginated data tables. This page covers every Vue component exported by the public module.

<PharenUiPreview name="data-grid" title="Data grid preview" />

<Accordion title="View code">
  ```vue theme={null}
  <script setup lang="ts">
  import { DataGrid, DataGridContainer, DataGridTable } from '@pharen/ui';
  import { getCoreRowModel, useVueTable, type ColumnDef } from '@tanstack/vue-table';

  type Member = { name: string; role: string };
  const data: Member[] = [{ name: 'Johannes', role: 'Owner' }];
  const columns: ColumnDef<Member>[] = [
    { accessorKey: 'name', header: 'Member' },
    { accessorKey: 'role', header: 'Role' },
  ];
  const table = useVueTable({ data, columns, getCoreRowModel: getCoreRowModel() });
  </script>

  <template>
    <DataGrid :table="table" :record-count="data.length">
      <DataGridContainer>
        <DataGridTable />
      </DataGridContainer>
    </DataGrid>
  </template>
  ```
</Accordion>

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npm install @pharen/ui
  ```

  ```bash pnpm theme={null}
  pnpm add @pharen/ui
  ```

  ```bash yarn theme={null}
  yarn add @pharen/ui
  ```

  ```bash bun theme={null}
  bun add @pharen/ui
  ```
</CodeGroup>

<Note>
  Import `@pharen/ui/styles.css` exactly once in your application entrypoint.
</Note>

## Usage

```ts theme={null}
import { DataGrid, DataGridColumnFilter, DataGridColumnHeader, DataGridColumnVisibility, DataGridContainer, DataGridPagination, DataGridScrollArea, DataGridTable, DataGridTableDnd, DataGridTableDndRowHandle, DataGridTableDndRows, DataGridTableVirtual } from '@pharen/ui';
```

## Exports

| Export                      | Purpose                                  |
| --------------------------- | ---------------------------------------- |
| `DataGrid`                  | Exported Vue component from this module. |
| `DataGridColumnFilter`      | Exported Vue component from this module. |
| `DataGridColumnHeader`      | Structures the header region.            |
| `DataGridColumnVisibility`  | Exported Vue component from this module. |
| `DataGridContainer`         | Exported Vue component from this module. |
| `DataGridPagination`        | Exported Vue component from this module. |
| `DataGridScrollArea`        | Exported Vue component from this module. |
| `DataGridTable`             | Exported Vue component from this module. |
| `DataGridTableDnd`          | Exported Vue component from this module. |
| `DataGridTableDndRowHandle` | Exported Vue component from this module. |
| `DataGridTableDndRows`      | Exported Vue component from this module. |
| `DataGridTableVirtual`      | Exported Vue component from this module. |

## Source

[Open the source on GitHub](https://github.com/PharenIT/ELEV8-Labs/tree/main/src/packages/ui/src/components/data-grid)
