- To reorder columns directly instead of via the actions menu popover,
- you can enable draggable EuiDataGrid header columns
- via the columnVisibility.canDragAndDropColumns{' '}
- prop. This will allow you to reorder the column by dragging them.
+ You can enable draggable EuiDataGrid header columns
+ with the
+ columnVisibility.canDragAndDropColumns prop to
+ reorder columns by dragging, instead of using the actions menu.
),
diff --git a/packages/website/docs/components/tabular_content/data_grid_schema_and_columns.mdx b/packages/website/docs/components/tabular_content/data_grid_schema_and_columns.mdx
index e3ad27a9aaf..4b85f462f5f 100644
--- a/packages/website/docs/components/tabular_content/data_grid_schema_and_columns.mdx
+++ b/packages/website/docs/components/tabular_content/data_grid_schema_and_columns.mdx
@@ -364,6 +364,103 @@ export default () => {
```
+## Draggable columns
+
+You can enable draggable `EuiDataGrid` header columns with the `columnVisibility.canDragAndDropColumns` prop to reorder columns by dragging, instead of using the actions menu.
+
+```tsx interactive
+import React, { useState, useCallback } from 'react';
+import { faker } from '@faker-js/faker';
+
+import { EuiDataGrid, EuiAvatar } from '@elastic/eui';
+
+const columns = [
+ {
+ id: 'avatar',
+ initialWidth: 40,
+ isResizable: false,
+ },
+ {
+ id: 'name',
+ initialWidth: 100,
+ },
+ {
+ id: 'email',
+ },
+ {
+ id: 'city',
+ },
+ {
+ id: 'country',
+ },
+ {
+ id: 'account',
+ },
+];
+
+const data = [];
+
+for (let i = 1; i < 5; i++) {
+ data.push({
+ avatar: (
+