Getting startedComponentsDesign tokensThemingTheme synthesizerFrameworksAccessibilityUtilitiesServer renderingBrowser supportContributingChangelogApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip
ARC UIARC Radiant Components
v4.9DocsComponentsTokensSynthesizer
Getting startedFrameworksServer renderingDesign tokensThemingTheme synthesizerTypographyUtilitiesAll componentsAccessibilityBrowser supportChangelogContributingStatsApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip

Data Grid

Grid for tabular data with inline editing, multi-column sorting, pinned columns, row selection and virtual scrolling. Columns are a JavaScript array, and the whole grid is one tab stop with the WAI-ARIA grid keyboard pattern.

ComponentsData Grid
datainteractivebeta
<arc-data-grid>

Overview

DataGrid renders `rows`, an array of objects, under `columns`, an array of `{ key, label }` entries. Both are set as JavaScript properties, not child elements. Each column can add `sortable`, `editable`, `pinned`, a fixed `width` and `align`. With none of those and `selectable` off, it's a plain read-only table. **It absorbed `arc-table` and `arc-data-table` in v4.** Three props came from them. `density="compact"` tightens cell padding. `striped` draws alternating row backgrounds and is on by default, so a plain Table migrates with `no-striped`. `overscan` sets how many rows render above and below the visible window when `virtual` is on (5 by default). Migrating: Table's positional `columns: ["A"]` and `rows: [["1"]]` become named keys (`[{ key, label }]`) and one object per row, so a column can move without every row moving with it. Data Table's slotted `<arc-column>` children become one `columns` entry each with the same field names, and its `sort-column`/`sort-direction` pair becomes a single entry in the multi-sort `sort` array, which behaves the same. Selection, virtual scrolling and `overscan` are unchanged. See the removal notes for [Table](/docs/components/table), [Data Table](/docs/components/data-table) and [Column](/docs/components/column). Clicking a sortable header cycles ascending, descending and off, and Shift+click adds the column as a secondary sort. With more than one sort active, each sorted header shows its arrow and a priority number. The grid sorts its own copy of the rows and fires `arc-sort` with the whole sort array. With `manual-sort`, it leaves the row order alone so you can sort on the server. In an editable column, Enter or a double-click opens an input in the cell. Enter or blur commits and fires `arc-cell-change` with `{ rowIndex, key, value, row }`, and Escape cancels. The grid works on a shallow copy, so sorting and edits never change the array you passed in: write edits back to your own data. Reassigning `rows` resets the selection and closes any open editor. The grid is one tab stop. Arrow keys move focus between cells, Home and End go to the ends of a row, Ctrl+Home and Ctrl+End to the corners, Enter sorts a header or edits a cell, and Space toggles row selection.

Guidelines

Do

  • For a display-only table, set `no-striped`. That's what the removed `arc-table` looked like
  • Set `manual-sort` and handle `arc-sort` when the data is paginated or sorted on the server
  • Pin one or two identifying columns, such as an ID or a name
  • Give pinned columns a `width`. Pinned offsets are computed from it
  • Turn on `virtual`, with an accurate `row-height`, for long datasets
  • Raise `overscan` if fast scrolling shows blank rows, and lower it if the number of rows in the DOM is the problem

Don't

  • Don't make every column editable. Limit editing to fields people need to change in place
  • Don't pin so many columns that the rest have no room on narrow screens
  • Don't use `virtual` with rows of different heights. It assumes every row is `row-height` tall
  • Don't raise `overscan` to cover a wrong `row-height`. The blank rows go away, but every scroll position stays slightly off
  • Don't use it for a list of one thing per row. Use `arc-list`, since grid semantics are wrong for that

Features

  • Pinned columns always come first and stick to the inline-start edge, with a shadow once the grid scrolls sideways
  • `selectable` adds a checkbox column. The header checkbox selects all and shows an indeterminate state for a partial selection, and `arc-select` sends indices into your original array
  • `virtual` renders only the visible rows plus the overscan buffer. `row-height` (40 by default) has to match the real row height
  • The header row stays in view while the body scrolls
  • CSS parts: `wrapper`, `table`, `header`, `header-cell`, `body`, `row`, `cell`, `editor`

Preview

Usage

This component needs JavaScript. Use the Web Component or a framework wrapper.

<arc-data-grid id="positions-grid" selectable></arc-data-grid>

<!-- Read-mostly, the way a plain arc-table looked: no selection, no
     editable columns, tighter rows, no stripes. -->
<arc-data-grid id="positions-readonly" density="compact" no-striped></arc-data-grid>

<script type="module">
  import '@arclux/arc-ui/data-grid';

  const grid = document.querySelector('#positions-grid');

  grid.columns = [
    { key: 'ticker', label: 'Ticker', width: '90px', pinned: true, sortable: true },
    { key: 'name', label: 'Company', width: '180px', sortable: true },
    { key: 'sector', label: 'Sector', sortable: true },
    { key: 'price', label: 'Price', align: 'right', sortable: true, editable: true },
    { key: 'change', label: 'Change %', align: 'right', sortable: true, editable: true }
  ];

  grid.rows = [
    { ticker: 'ARC', name: 'Arclight Systems', sector: 'Technology', price: 142.5, change: 2.4 },
    { ticker: 'LUM', name: 'Lumen Dynamics', sector: 'Energy', price: 87.2, change: -1.1 },
    { ticker: 'NVA', name: 'Nova Materials', sector: 'Industrials', price: 56.8, change: 0.7 }
  ];

  grid.addEventListener('arc-cell-change', (e) => {
    const { rowIndex, key, value } = e.detail;
    // write the edit back to your own data store
    console.log('edited', rowIndex, key, value);
  });

  grid.addEventListener('arc-sort', (e) => console.log('sort', e.detail.sort));
  grid.addEventListener('arc-select', (e) => console.log('selected', e.detail.selectedIndices));
</script>

API

columnsArray<{key:string,label:string,sortable?:boolean,editable?:boolean,pinned?:boolean,width?:string,align?:string}>[]
Column definitions. Each entry maps a key in your row objects to a rendered column with a label header. Optional flags enable sorting, inline editing, and inline-start-edge pinning per column; width sets a fixed CSS width (required for accurate pinned offsets) and align controls text alignment. Pinned columns are always displayed first. Set via JavaScript property.
rowsArray<Record<string, any>>[]
The data array. Each object becomes a row keyed by column key. The grid works on an internal shallow copy; sorting and inline edits never mutate the array you pass in. Set via JavaScript property; reassigning it resets selection and any open editor.
sortArray<{key:string,direction:'asc'|'desc'}>[]
Multi-sort state in priority order. Clicking a sortable header cycles it asc → desc → none; Shift+click appends it as a secondary sort. When more than one sort is active, headers show a direction arrow plus priority number. Set this property to pre-sort the grid.
manualSortbooleanfalse
Skips internal sorting. Rows render in the order given, while headers still cycle the sort state and emit arc-sort; use this to implement server-side sorting.
selectablebooleanfalse
Adds a checkbox column with a select-all header checkbox (indeterminate when partially selected). Space toggles selection from the keyboard. Emits arc-select with the selected row indices.
virtualbooleanfalse
Enables virtual scrolling for large datasets. Only visible rows plus an overscan buffer are rendered, keeping performance constant regardless of row count.
rowHeightnumber40
Height in pixels of each row when virtual scrolling is enabled. Must match the actual rendered row height for correct scroll calculations.
overscannumber5
Rows rendered above and below the visible window when virtual is on, to cover fast scrolling. Raising it trades DOM nodes for fewer blank rows on a fling; lowering it does the reverse. Never negative.
density'default' | 'compact''default'
Row density. compact reduces cell padding for dense data displays. Absorbed from arc-table.
stripedbooleantrue
Alternating row backgrounds. On by default, which is what this grid has always drawn; no-striped turns them off, which is what an unstriped arc-table looked like.

Events

arc-sort
Fired when the user changes sorting. detail: { sort } with the full multi-sort array in priority order
arc-select
Fired when row selection changes. detail: { value, selectedIndices }, where selectedIndices are sorted indices into the original rows array
arc-cell-change
Fired when an inline cell edit is committed. detail: { rowIndex, key, value, row }; rowIndex refers to the original rows array

See also