Grid
shadcn-htmx/gridFreeComponent
An interactive data grid built on a real <table role="grid">: a single tab stop with 2-D arrow-key cell navigation (roving tabindex), Home/End to row ends, and Ctrl+Home/End to the grid corners.
Live preview
live · rendered by the registry
Rendered by shadcn-htmx on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://shadcn-htmx.productdevbook.com/r/grid.jsonSource
1/** @jsxImportSource hono/jsx */2import type { PropsWithChildren } from "hono/jsx"3import { cn, type ClassValue } from "@/registry/lib/cn"45// Grid — shadcn-htmx, htmx v4 + Tailwind v4.6//7// An INTERACTIVE data grid: a single tab stop with 2-D arrow-key cell8// navigation (roving tabindex). This is deliberately distinct from the9// static <Table> component — Table is the right choice for read-only10// tabular data (every focusable link/button stays in the tab sequence and11// AT gets native row/column navigation). Reach for Grid only when you want12// spreadsheet-style cell focus and a SHORTER tab sequence (the whole grid13// is one tab stop). See the APG comparison of the two patterns.14//15// shadcn/ui has no Grid component — this maps to the WAI-ARIA APG Grid16// pattern, built on a real <table> so we inherit the semantic table model17// and only layer the grid roles + roving tabindex on top.18//19// Refs (read before editing):20// repos/aria-practices/content/patterns/grid/grid-pattern.html21// — keyboard contract + roles/states. Arrow keys move one cell; Home/End22// jump to row ends; Ctrl+Home/End jump to the grid's first/last cell.23// repos/aria-practices/content/patterns/grid/examples/js/dataGrid.js24// — the reference roving-tabindex implementation we model (one cell at25// tabindex="0", the rest at -1; setFocusPointer rolls the 0).26// repos/mdn/files/en-us/web/html/reference/elements/table/index.md27// repos/mdn/files/en-us/web/accessibility/aria/reference/roles/grid_role/index.md28//29// The ARIA contract:30// - The container is a <table role="grid"> with an accessible name31// (aria-label or aria-labelledby). role="grid" switches screen readers32// into application mode so the arrow-key contract is exposed.33// - Native <tr> carries the implicit role="row"; <th scope="col"> the34// implicit role="columnheader"; <td> the implicit role="gridcell". We35// keep the native elements and do NOT add aria-rowspan/colspan — per the36// APG note, a grid built from a <table> must use HTML rowspan/colspan.37// - Every focusable cell is marked [data-grid-cell] so the keyboard layer38// can build its 2-D map. Exactly one carries tabindex="0"; the rest -1.39// - If a cell contains a single interactive widget (link/button), grid40// navigation focuses that widget directly (APG "focus an element inside41// the cell"); otherwise it focuses the cell itself. We expose that via42// … truncated
More from shadcn-htmx
All 83 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | shadcn-htmx | Components | Free | no deps | |
| Active Searchactive-search | shadcn-htmx | Components | Free | no deps | |
| Alertalert | shadcn-htmx | Components | Free | no deps | |
| Alert Dialogalert-dialog | shadcn-htmx | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | shadcn-htmx | Components | Free | no deps | |
| Auto Gridauto-grid | shadcn-htmx | Components | Free | no deps | |
| Autocompleteautocomplete | shadcn-htmx | Components | Free | no deps | |
| Autosize Textareaautosize-textarea | shadcn-htmx | Components | Free | no deps |
