Skip to content
Drivn
5 min read

Drivn vs shadcn/ui — Table Compared

A data Table is one of the few shadcn components with no Radix under it — so this comparison is about API shape, built-in variants, and how the source reads.

Most shadcn/ui components wrap a Radix primitive, but the Table does not, so comparing it with Drivn is not a story about dependency counts. Both libraries render a plain semantic <table> inside a horizontally scrolling wrapper, both rely on a cn() class-merge helper and nothing else, and neither needs a React hook to draw rows. The differences show up in how you write the table and how much styling you have to do by hand.

Drivn ships one file at packages/drivn/src/registry/components/table.ts. A single Table export carries seven sub-components through Object.assign — Caption, Header, Body, Footer, Row, Head, and Cell — so one import line covers the whole tree. Every class sits in a const styles object, the root takes a variant prop typed as keyof typeof styles.variants for default, striped, and bordered looks, and Table.Head sets scope="col" unless you pass another value.

shadcn/ui exposes the same parts as eight flat named exports, from Table and TableHeader through TableFooter and TableCaption, each with its own inline cn() call and no variant prop. Zebra rows or cell borders mean writing the selectors yourself.

The sections below compare the import shape, the built-in variants, attribute-driven alignment, and what each library offers once a table needs sorting and row selection.

Side-by-side comparison

FeatureDrivnshadcn/ui
Install commandnpx drivn add tablenpx shadcn@latest add table
Runtime UI dependenciescn() utility only — zero npm UI packagescn() utility only — Table is not Radix-backed
API shapeDot notation — Table.Header, Table.CellNamed exports — TableHeader, TableCell
Import statementOne name: import { Table }Up to eight names imported flat
Built-in variantsdefault / striped / bordered via variant propNone — add classes manually
Cell alignmentalign prop → CSS attribute selectorclassName="text-center" per cell
Styling patternSingle const styles objectInline cn() per sub-component
Sorting + row selectionDrivn Data Table built on Table — no TanStackRecipe on top of @tanstack/react-table
React hooks in TableNone — no 'use client' directiveNone — plain markup wrappers
LicenseMITMIT

One import, dot notation — Table.Header not TableHeader

Drivn attaches every table part to the root via Object.assign(TableRoot, { Caption, Header, Body, Footer, Row, Head, Cell }), so a single import { Table } from "@/components/ui/table" gives you the whole set. You write Table.Header, Table.Row, Table.Head, and Table.Cell — the structure reads like the HTML it renders, and your import block stays one line no matter how complex the table grows.

shadcn/ui exports each part separately, so the same table needs import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell } from "@/components/ui/table" — six or seven names to keep in sync as you add a caption or footer. The flat naming is a matter of taste, but the dot notation means one import line and a component tree that mirrors <thead> / <tbody> / <tr> / <th> / <td> without the Table prefix repeated on every tag. See the full API on the Table reference.

1import { Table } from "@/components/ui/table"
2
3export default function Page() {
4 return (
5 <Table>
6 <Table.Header>
7 <Table.Row>
8 <Table.Head>Name</Table.Head>
9 <Table.Head>Role</Table.Head>
10 <Table.Head>Status</Table.Head>
11 </Table.Row>
12 </Table.Header>
13 <Table.Body>
14 <Table.Row>
15 <Table.Cell>Alice</Table.Cell>
16 <Table.Cell>Engineer</Table.Cell>
17 <Table.Cell>Active</Table.Cell>
18 </Table.Row>
19 <Table.Row>
20 <Table.Cell>Bob</Table.Cell>
21 <Table.Cell>Designer</Table.Cell>
22 <Table.Cell>Active</Table.Cell>
23 </Table.Row>
24 </Table.Body>
25 </Table>
26 )
27}

Built-in striped and bordered variants

Drivn bakes three visual styles into a variant prop — default, striped, and bordered — typed as keyof typeof styles.variants so your editor autocompletes the three options and rejects typos. Switching a plain table to zebra striping is <Table variant="striped">; adding cell borders is <Table variant="bordered">. The classes that drive each variant live in the styles.variants object, applied to the root <table> and cascading to tbody rows via Tailwind arbitrary selectors.

shadcn/ui ships no variant prop on its table. To stripe rows you add an [&_tr:nth-child(even)] background utility to the TableBody className yourself; to border cells you append border utilities to every TableHead and TableCell. It is the same Tailwind under the hood, but Drivn pre-packages the common cases behind one type-safe prop so you do not re-derive the arbitrary selectors for each table you build.

1// packages/drivn/src/registry/components/table.ts — verbatim
2variants: {
3 default: '',
4 striped: '[&_tbody_tr:nth-child(even)]:bg-muted/30',
5 bordered: cn(
6 '[&_th]:border [&_td]:border',
7 '[&_th]:border-border [&_td]:border-border',
8 '[&_tbody_tr:nth-child(even)]:bg-muted/30'
9 ),
10},

Cell alignment via a native attribute selector

Both Table.Head and Table.Cell accept an align prop, but Drivn wires it through the native HTML align attribute rather than a className. The styles.head and styles.cell entries include [&[align=center]]:text-center and [&[align=right]]:text-right — Tailwind arbitrary attribute selectors that match the rendered align="center" or align="right" on the <th> / <td>. So <Table.Cell align="center">$29</Table.Cell> centres the cell with zero extra classes, and the alignment travels with the semantic attribute.

shadcn/ui leaves alignment to you — you pass className="text-center" on each TableCell you want centred. The rendered output is identical, but Drivn's attribute-driven approach keeps the alignment declarative and out of the className soup, which matters when a pricing or comparison table has a dozen right-aligned number columns. The verbatim head and cell style entries show how the selectors map onto the attribute.

1// packages/drivn/src/registry/components/table.ts — verbatim
2head: cn(
3 'px-4 py-2.5 text-left font-semibold',
4 'text-muted-foreground',
5 '[&[align=center]]:text-center',
6 '[&[align=right]]:text-right'
7),
8cell: cn(
9 'px-4 py-2.5 text-foreground',
10 '[&[align=center]]:text-center',
11 '[&[align=right]]:text-right'
12),

Sorting and row selection without TanStack

shadcn/ui answers sorting and row selection with a recipe: install @tanstack/react-table, define your columns for it, then map getHeaderGroups() and getRowModel() onto the flat table exports. Drivn ships that layer as a component instead. The Data Table is built directly on Table, Checkbox, Skeleton, and Pagination, with no headless table package in between. Columns are plain objects with an id and a header, plus optional cell, align, width, and sortable fields. Clicking a sortable header cycles ascending, descending, then unsorted, and selectable adds a checkbox column whose header box turns indeterminate when only some rows are picked.

Because it renders Table.Head and Table.Cell underneath, the variant prop and align handling from the sections above carry straight through. A table that already depends on TanStack can still sit on the Drivn Table: map header groups onto Table.Head, rows onto Table.Cell, and leave the headless logic as it is.

1"use client"
2
3import * as React from "react"
4import { DataTable } from "@/components/ui/data-table"
5
6const users = [
7 { id: 1, name: "Alice", role: "Engineer", status: "Active" },
8 { id: 2, name: "Bob", role: "Designer", status: "Away" },
9]
10
11const columns = [
12 { id: "name", header: "Name" },
13 { id: "role", header: "Role" },
14 { id: "status", header: "Status" },
15]
16
17export default function Team() {
18 const [selected, setSelected] = React.useState<Set<string>>(new Set())
19
20 return (
21 <DataTable
22 data={users}
23 columns={columns}
24 rowKey="id"
25 variant="striped"
26 sortable
27 selectable
28 onSelectionChange={setSelected}
29 footer={<p>{selected.size} selected</p>}
30 />
31 )
32}
Get started

Install Drivn in one command

Copy the source into your project and own every line. Zero runtime dependencies, pure React + Tailwind.

npx drivn@latest create

Requires Node 18+. Works with npm, pnpm, and yarn.

Enjoying Drivn?
Star the repo on GitHub to follow new component releases.
Star →

Frequently asked questions

No. The Drivn Table is a single file at packages/drivn/src/registry/components/table.ts that imports React and the local cn() utility from @/utils/cn — nothing else. It renders plain semantic table, thead, tbody, tr, th, and td elements. Notably, shadcn/ui's Table is also dependency-free here — the table is one of the few shadcn components that does not wrap a Radix primitive, so neither library adds a runtime UI package for this component.

Drivn uses dot notation — one import of { Table } gives you Table.Header, Table.Body, Table.Row, Table.Head, Table.Cell, Table.Footer, and Table.Caption attached to the root via Object.assign. shadcn/ui exports each part as a separate name — TableHeader, TableBody, TableRow, and so on — which you import flat. Same rendered markup, but Drivn keeps the import to one line and the tree mirrors the underlying HTML structure.

Yes. Pass variant="striped" on the Table root and the styles.variants.striped entry applies [&_tbody_tr:nth-child(even)]:bg-muted/30, tinting every even body row. There is also variant="bordered" for cell borders plus striping. shadcn/ui has no variant prop, so the same zebra effect there means adding the nth-child arbitrary selector to the TableBody className by hand each time.

Yes. The Table source has no 'use client' directive and no React hooks — it is pure presentational markup, so it renders on the server with zero client JavaScript for the table itself. You only need a client component when you add interactivity like column sorting, and even then only the interactive wrapper needs 'use client', not the Table primitives.

Pass align="right" on the Table.Head and Table.Cell for that column. Drivn forwards it as the native HTML align attribute, and the head and cell style entries include [&[align=right]]:text-right, a Tailwind attribute selector that right-aligns the text. This keeps alignment declarative and tied to the semantic attribute rather than scattered className="text-right" strings on every numeric cell.

Yes. Because the Drivn Table is plain markup with no internal state, you can drive it with @tanstack/react-table the same way shadcn does — call useReactTable for the headless model, then map getHeaderGroups and getRowModel onto Table.Header, Table.Row, Table.Head, and Table.Cell. For column sorting and row selection alone, the Drivn Data Table already covers both on top of the same Table primitives, so you may not need TanStack at all.