Expandable Row Table
ProOrders table where each row opens a full-width detail row with line items, a totals ledger, the shipping address and an internal note. Use it when a record has child data that does not need its own page.
How it differs. A disclosure button per row reveals a detail row spanning all columns, split into line items and an address and note rail. Several rows stay open and the header button opens them all.
Install
pnpm dlx shadcn@latest add @hazine/data-table-expandable-rowsAdds 3 files, 3 shadcn primitives (badge, button, table), 2 Hazine items (@hazine/heading, @hazine/use-controllable-state), 1 package (lucide-react), and the warning token.
First time? Add the registry to components.json
{
"registries": {
"@hazine": {
"url": "https://api.hazine.dev/r/{name}.json",
"headers": { "Authorization": "Bearer ${HAZINE_TOKEN}" }
}
}
}Set HAZINE_TOKEN in your environment. The token comes with a Pro licence.
The source of a Pro item is not published on this site. It installs into your codebase with the same command once your registry entry carries a Pro token.
- components/blocks/data-table-expandable-rows.tsx
- 443 lines
- components/blocks/data-table-expandable-rows.detail.tsx
- 216 lines
- components/blocks/data-table-expandable-rows.orders.ts
- 178 lines
- 3 files
- 837 lines
pnpm dlx shadcn@latest add @hazine/data-table-expandable-rowsAdds 3 files, 3 shadcn primitives (badge, button, table), 2 Hazine items (@hazine/heading, @hazine/use-controllable-state), 1 package (lucide-react), and the warning token.
Props12
- title
- string = "Trade orders"
- headingLevel
- HeadingLevel = 2
- orders
- Order[] = DEFAULT_ORDERS
- expanded
- string[]
- Ids of the orders whose detail row is open.
- defaultExpanded
- string[] = DEFAULT_EXPANDED
- onExpandedChange
- (expanded: string[]) => void
- taxRate
- number = 0.21
- Tax on line items plus shipping, as a fraction. 0.21 is 21%.
- loading
- boolean = false
- Replaces the rows with skeleton rows while the consumer fetches.
- error
- string
- What went wrong and what to do next. Rendered in an alert above the table.
- currency
- string = "EUR"
- locale
- string = "en-US"
- createHref
- string = "/orders/new"
- Target of the one action in the empty state.
Also accepts every prop of Omit< React.ComponentProps<"section">, "title" >.
Accessibility
- Pattern
- Data table, Disclosure (APG, opens in a new tab), Table (APG, opens in a new tab)
- Keyboard
Keyboard support for Expandable Row Table Key Effect Tab Moves from the expand all button through the details button of each row in order. The email link of an open row follows its button Enter or Space on a details button Opens or closes the detail row of that order. Focus stays on the button and other rows keep their state Enter or Space on Expand all orders Opens every row, or closes them all when all are open. Focus stays on the button and its name changes to match Enter on an email link Starts an email to the customer of that order Enter on Create an order Follows the link of the empty state, the only control when there are no orders - Screen reader
Native table with a caption, column headers and the order number as row header. Each row starts with a button carrying aria-expanded and aria-controls that points at the detail row. The detail holds a nested line items table with its own caption.
- Announces: All {count} orders expanded.
- Announces: 1 order expanded.
- Announces: All orders collapsed.
- Announces: {open} of {count} rows open.
- Announces: Loading orders.
- Reduced motion
- Rows open without animation. The loading skeleton does not pulse. Colour transitions only.
- Checked
- Not checked yet. Automated results appear here once CI has run.
Dependencies6
- badge
- button
- table
- @hazine/heading
- @hazine/use-controllable-state
- lucide-react
Filled chips are registry items the CLI adds for you. Outlined chips are npm packages.
Tokens shipped2
- --warning
- --warning-foreground
Added to your stylesheet in light and dark, unless you already define them.