Skip to main content

Responsive Columns

OGrid can automatically hide lower-priority columns when the grid container becomes narrow, keeping the most important data visible on smaller screens. Columns are progressively hidden based on responsivePriority values and configurable width breakpoints.

How It Works

  1. Assign responsivePriority to columns (0 = highest priority, always visible).
  2. Enable responsiveColumns on the grid.
  3. As the container width shrinks below breakpoint thresholds, columns with higher priority numbers are hidden first.

Default Breakpoints

Container WidthMax Priority Shown
< 576px0 only
576–767px0–1
768–991px0–2
992–1199px0–3
>= 1200pxAll columns

Rules

  • Columns without responsivePriority are never auto-hidden.
  • Columns with required: true are never auto-hidden regardless of priority.
  • Responsive hiding works alongside the Column Chooser - columns hidden by the user stay hidden.

Quick Example

import { OGrid } from '@alaarab/ogrid-react-radix';

const columns = [
{ columnId: 'name', name: 'Name', responsivePriority: 0 }, // always visible
{ columnId: 'email', name: 'Email', responsivePriority: 1 }, // hidden < 576px
{ columnId: 'department', name: 'Dept', responsivePriority: 2 }, // hidden < 768px
{ columnId: 'phone', name: 'Phone', responsivePriority: 3 }, // hidden < 992px
{ columnId: 'address', name: 'Address', responsivePriority: 4 }, // hidden < 1200px
];

function App() {
return (
<OGrid
columns={columns}
data={items}
getRowId={(item) => item.id}
responsiveColumns
/>
);
}
tip

Also available from @alaarab/ogrid-react-fluent and @alaarab/ogrid-react-material.

Custom Breakpoints

Override the default breakpoints by passing a config object instead of true:

<OGrid
columns={columns}
data={items}
getRowId={(item) => item.id}
responsiveColumns={{
breakpoints: [
{ minWidth: 0, maxPriority: 0 }, // < 480px: only priority 0
{ minWidth: 480, maxPriority: 2 }, // 480-799px: priority 0-2
{ minWidth: 800, maxPriority: Infinity }, // >= 800px: all columns
],
}}
/>

Core Utility

The responsive column logic is available as a standalone pure function for advanced use cases:

import { getResponsiveHiddenColumns } from '@alaarab/ogrid-core';

const hidden = getResponsiveHiddenColumns(containerWidth, columns);
// Returns Set<string> of column IDs to hide