HomeDocsComponentsBlocksChartsThemes
Introduction
  • Introduction
  • Installation
  • Themes
  • Artwork
  • llms.txt
Components
  • Accordion
  • Alert
  • Alert Dialog
  • Amount
  • Aspect Ratio
  • Audio Player
  • Avatar
  • Avatar Upload
  • Badge
  • Banner
  • Brand SVG
  • Breadcrumb
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Code Block
  • Collapsible
  • Color Picker
  • Combobox
  • Command
  • Context Menu
  • Copy Button
  • Countdown
  • Data Grid
  • Data Table
  • Date Picker
  • Date Range Picker
  • Description List
  • Device Mockup
  • Dialog
  • Direction
  • Dot Loader
  • Drawer
  • Dropdown Menu
  • Empty
  • Field
  • File Upload
  • Form Guide
  • Hover Card
  • Icon Tile
  • Image Export
  • Input
  • Input Group
  • Input OTP
  • Item
  • Kanban
  • Kbd
  • Label
  • League Table
  • Marquee
  • Match Score
  • Meter
  • Multi Select
  • Native Select
  • Number Field
  • Pagination
  • Password Strength
  • Phone Input
  • Popover
  • Progress
  • Progress Circle
  • Radio Group
  • Rating
  • Resizable
  • Responsive Dialog
  • Rich Text Editor
  • Scroll Area
  • Segmented Control
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature
  • Skeleton
  • Slider
  • Sonner
  • Sortable
  • Spinner
  • Stat
  • Stat Tabs
  • Stepper
  • Switch
  • Table
  • Tabs
  • Tag Input
  • Terminal
  • Textarea
  • Time Field
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Tree
  • Typography
  • Video Player
  • Window Mockup
  • Accordion
  • Alert
  • Alert Dialog
  • Amount
  • Aspect Ratio
  • Audio Player
  • Avatar
  • Avatar Upload
  • Badge
  • Banner
  • Brand SVG
  • Breadcrumb
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Code Block
  • Collapsible
  • Color Picker
  • Combobox
  • Command
  • Context Menu
  • Copy Button
  • Countdown
  • Data Grid
  • Data Table
  • Date Picker
  • Date Range Picker
  • Description List
  • Device Mockup
  • Dialog
  • Direction
  • Dot Loader
  • Drawer
  • Dropdown Menu
  • Empty
  • Field
  • File Upload
  • Form Guide
  • Hover Card
  • Icon Tile
  • Image Export
  • Input
  • Input Group
  • Input OTP
  • Item
  • Kanban
  • Kbd
  • Label
  • League Table
  • Marquee
  • Match Score
  • Menubar
  • Meter
  • Multi Select
  • Native Select
  • Navigation Menu
  • Number Field
  • Pagination
  • Password Strength
  • Phone Input
  • Popover
  • Progress
  • Progress Circle
  • Radio Group
  • Rating
  • Resizable
  • Responsive Dialog
  • Rich Text Editor
  • Scroll Area
  • Segmented Control
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature
  • Skeleton
  • Slider
  • Sortable
  • Spinner
  • Stat
  • Stat Tabs
  • Stepper
  • Switch
  • Table
  • Tabs
  • Tag Input
  • Terminal
  • Textarea
  • Time Field
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Tree
  • Typography
  • Video Player
  • Window Mockup
  • Accordion
  • Alert
  • Alert Dialog
  • Amount
  • Aspect Ratio
  • Audio Player
  • Avatar
  • Avatar Upload
  • Badge
  • Banner
  • Brand SVG
  • Breadcrumb
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Cart Button
  • Cart Line Item
  • Cart Summary
  • Chart
  • Checkbox
  • Code Block
  • Collapsible
  • Color Picker
  • Combobox
  • Command
  • Context Menu
  • Copy Button
  • Countdown
  • Data Grid
  • Data Table
  • Date Picker
  • Date Range Picker
  • Description List
  • Device Mockup
  • Dialog
  • Direction
  • Dot Loader
  • Drawer
  • Dropdown Menu
  • Empty
  • Field
  • Fill Blank
  • File Icon
  • File Upload
  • Form Guide
  • Hover Card
  • Icon Tile
  • Image Export
  • Input
  • Input Group
  • Input OTP
  • Item
  • Kanban
  • Kbd
  • Label
  • League Table
  • Marquee
  • Match Score
  • Menubar
  • Meter
  • Multi Select
  • Native Select
  • Navigation Menu
  • Number Field
  • Pagination
  • Password Strength
  • Person Avatar
  • Phone Input
  • Popover
  • Price
  • Product Card
  • Progress
  • Progress Circle
  • Radio Group
  • Rating
  • Resizable
  • Responsive Dialog
  • Rich Text Editor
  • Scroll Area
  • Segmented Control
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature
  • Skeleton
  • Slider
  • Sonner
  • Sortable
  • Spinner
  • Stat
  • Stat Tabs
  • Stepper
  • Switch
  • Table
  • Tabs
  • Tag Input
  • Terminal
  • Textarea
  • Time Field
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Tree
  • Typography
  • Video Player
  • Window Mockup
  • Accordion
  • Alert Dialog
  • Alert
  • Amount
  • Aspect Ratio
  • Audio Player
  • Avatar Upload
  • Avatar
  • Badge
  • Banner
  • Bot Avatar
  • Brand SVG
  • Breadcrumb
  • Button Group
  • Button
  • Calendar
  • Card
  • Carousel
  • Cart Button
  • Cart Line Item
  • Cart Summary
  • Chart
  • Checkbox
  • Code Block
  • Collapsible
  • Color Picker Primitive
  • Combobox
  • Command
  • Context Menu
  • Copy Button
  • Countdown
  • Data Grid
  • Data Table
  • Date Picker
  • Date Range Picker
  • Description List
  • Device Mockup
  • Dialog
  • Direction
  • Dot Loader
  • Drawer
  • Dropdown Menu
  • Empty
  • Field
  • File Icon
  • File Upload
  • Fill Blank
  • Form Guide
  • Hover Card
  • Icon Tile
  • Image Export
  • Input Group
  • Input OTP
  • Input
  • Item
  • Kanban
  • Kbd
  • Label
  • League Table
  • Marquee
  • Match Score
  • Menubar
  • Meter
  • Multi Select
  • Native Select
  • Navigation Menu
  • Number Field
  • Pagination
  • Password Strength
  • Person Avatar
  • Phone Input
  • Popover
  • Price
  • Product Card
  • Progress Circle
  • Progress
  • Radio Group
  • Rating
  • Resizable
  • Responsive Dialog
  • Rich Text Editor
  • Scroll Area
  • Segmented Control
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature
  • Skeleton
  • Slider
  • Sonner
  • Sortable
  • Spinner
  • Stat Tabs
  • Stat
  • Stepper
  • Switch
  • Table
  • Tabs
  • Tag Input
  • Terminal
  • Textarea
  • Time Field
  • Timeline
  • Toggle Group
  • Toggle
  • Tooltip
  • Tree
  • Video Player
  • Window Mockup
AI
  • Message Scroller
  • Message
  • Bubble
  • Marker
  • Attachment
  • Questionnaire
  • Composer
  • Reasoning
  • Tool Call
  • Approval Card
  • Citations
  • Message Toolbar
Blocks
  • Airtable
  • Airtable Kanban
  • CRM
  • ClickUp List
  • ClickUp Kanban
  • Repeatable Group
  • Command Palette
  • App Shell
  • Record Files
  • Settings Shell
  • Help Panel
  • Note Editor
  • Email Drafts
  • Task List
  • Notifications Panel
  • Dual Pane Sidebar
  • Team Members Panel
  • Mix Pack Builder
  • Record Picker and Date Quick-pick
  • Record List
  • Record Page
  • Sign In and Sign Up
  • Availability Scheduler
  • AI Chat
  • AI Assistant
  • Voice Message
  • Action Bar
  • Notion
  • Banking
  • Lineup Builder
  • Sports Score
  • Standings
  • Strava
  • Sheets
  • Notices
  • Settings
  • Billing
Templates
  • Sign In Page
  • Upload Page
  • Showcase Onboarding
  • Agreement Sign
  • Email
  • Email Composer
  • Share Dialog
  • Integrations
  • Transactions
  • Analytics
Utilities
  • motion
  • sounds
  • scroll-fade
  • shimmer
Another UI. Built on shadcn/ui with Phosphor icons.

Data Grid

PreviousNext

A spreadsheet surface with lettered columns, numbered rows, an active cell, range selection, in-cell editing and copy and paste. Built on TanStack Table and the Table primitive.

UI SDKBase UIReact AriaRadix UI
ABCDEFGHIJKLMNOPQRSTUVWXYZ
1DateVendorCategoryAmount
2Oct 1Chilliwack Office SupplyOffice$48.20
3Oct 2TelusPhone$95.00
4Oct 4AdobeSoftware$29.99
5Oct 7Petro-CanadaTravel$71.35
6Oct 9Mount Cheam CoffeeMeals$18.75
7Oct 12FigmaSoftware$22.00
8Oct 15BC HydroUtilities$112.48
9Oct 18StaplesOffice$36.10
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
D2:D9Sum: $433.87

The demo renders with the docs site's own Radix-based parts. The same component with the UI SDK parts was run side by side with it in a browser and behaves the same.

Installation#

On the UI SDK base this is the same file as on Radix. It uses Input, Table and Scroll Fade Area from your own components/ui, so a UI SDK project gets the UI SDK versions, and selection, range select, editing, keyboard movement and scrolling a moving selection into view behave as they do on Radix.

pnpm dlx shadcn@latest add https://anotherui.dev/r/data-grid.json

Usage#

import { DataGrid, type GridCellChange } from "@/components/ui/data-grid"
const [cells, setCells] = React.useState<Record<string, string>>({})
 
const getRawValue = React.useCallback((row: number, col: number) => cells[`${row}:${col}`] ?? "", [cells])
const getCell = React.useCallback(
  (row: number, col: number) => {
    const raw = cells[`${row}:${col}`]
    return raw ? { content: raw } : null
  },
  [cells]
)
 
<DataGrid
  rowCount={100}
  columnCount={26}
  getCell={getCell}
  getRawValue={getRawValue}
  onCellsChange={(changes: GridCellChange[]) => {
    setCells((prev) => {
      const next = { ...prev }
      for (const { row, col, value } of changes) next[`${row}:${col}`] = value
      return next
    })
  }}
  frozenRows={1}
  className="h-96"
/>

Data Grid or Data Table#

Use Data Table for records: one row per item, with sorting, filters and pages. Use Data Grid when people work on cells: pick a cell, type, select a range, copy it into another app. The Sheets block is a full spreadsheet on it.

Keyboard and mouse#

  • Move. Arrows, Tab and Shift Tab, Home and End, Page Up and Page Down. Ctrl or Cmd with an arrow jumps to the edge.
  • Select. Shift with an arrow or a click, or drag across cells. Click a letter or number to take the whole column or row, and the corner for everything. Ctrl A selects all.
  • Edit. Start typing to replace a cell, or press Enter, F2 or double click to edit what is there. Enter saves and moves down, Tab saves and moves right, Escape cancels.
  • Clipboard. Ctrl C, X and V copy, cut and paste ranges as tab separated text, so they round trip with Google Sheets and Excel. One copied value pasted over a range fills it. Delete clears the range.
  • Columns. Drag the edge of a column header to resize it, and double click the edge to reset it.

On touch, a tap selects a cell, a second tap edits it, and swipes scroll the grid.

Props#

  • Data. rowCount and columnCount. getCell(row, col) returns what a cell shows: content, align, wrap, className and style, or null for empty. getRawValue returns what it edits and copies, such as a formula. Keep both stable with useCallback, since rows only repaint when they change.
  • Changes. onCellsChange gets every edit, paste and clear as one batch of { row, col, value }.
  • Selection. selection and onSelectionChange, or defaultSelection. The anchor is the active cell and focus is the other corner. gridRange, rangeName and cellName turn them into "B3:D9" style names.
  • Layout. columnSizing and onColumnSizingChange by column letter, defaultColumnWidth, rowHeight, zoom, frozenRows, frozenColumns, merges for horizontal merges keyed "row:col", and gridlines.
  • Editing extras. onDraftChange reports the draft while a cell is open, so a formula bar can follow it. getSuggestions shows a list under the editor, picked with the arrows and Tab. transformPaste and onCopyRange let you rewrite pasted values, like shifting formula references.
  • Ref. focus(), edit(initial), select(selection), copy(cut) and paste(text).

The grid scrolls on both axes inside its own frame, with the header row and row numbers pinned and the edges fading where there is more to see.

CountdownData Table

On This Page

InstallationUsageData Grid or Data TableKeyboard and mouseProps