Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(quill): add composable Table primitive (#60763)

Adam Leith76744f83bc15
diff --git a/packages/quill/apps/storybook/.storybook/storybook.css b/packages/quill/apps/storybook/.storybook/storybook.css
index 63d9bee7414c..ea07e5ee0c96 100644
--- a/packages/quill/apps/storybook/.storybook/storybook.css
+++ b/packages/quill/apps/storybook/.storybook/storybook.css
@@ -47,6 +47,15 @@
*/
@import '../../../packages/primitives/src/styles/layers.css';
+/*
+ * Primitive BEM styles, from the built package. Components stories (e.g.
+ * DataTable) import primitives via `@posthog/quill-primitives`, whose JS does
+ * NOT inject CSS — so without this they render with classnames but no styles.
+ * The primitives' OWN stories import from source and still hot-reload their BEM;
+ * this only backstops cross-package consumers. Rebuild primitives to refresh.
+ */
+@import '../../../packages/primitives/dist/quill-primitives.css';
+
/*
* Scan sources, not dist. Vite HMR forwards any .tsx change in these
* trees to Tailwind's scanner and we get new utilities emitted on the
diff --git a/packages/quill/packages/blocks/package.json b/packages/quill/packages/blocks/package.json
index 8bbbea01c5c5..1f0ffedce272 100644
--- a/packages/quill/packages/blocks/package.json
+++ b/packages/quill/packages/blocks/package.json
@@ -1,6 +1,6 @@
{
"name": "@posthog/quill-blocks",
- "version": "0.3.0-beta.10",
+ "version": "0.3.0-beta.12",
"private": true,
"description": "Internal workspace package (private, not published). The highest layer of the quill design system — product-level patterns made of components + primitives (e.g. a PageHeader with title + breadcrumb + action slot, an EmptyState with icon + copy + CTA, a CommandPalette, a user-menu dropdown). Opinionated and shape-stable across products so they feel consistent. Bundled into @posthog/quill at build time; consumers should import from @posthog/quill instead.",
"license": "MIT",
diff --git a/packages/quill/packages/components/package.json b/packages/quill/packages/components/package.json
index e11640e77361..db7326d03b38 100644
--- a/packages/quill/packages/components/package.json
+++ b/packages/quill/packages/components/package.json
@@ -1,6 +1,6 @@
{
"name": "@posthog/quill-components",
- "version": "0.3.0-beta.10",
+ "version": "0.3.0-beta.12",
"private": true,
"description": "Internal workspace package (private, not published). The middle layer of the quill design system — higher-level compositions of primitives that wire several of them together with sensible defaults (e.g. a FormField that composes Label + Input + validation state, or a ConfirmDialog that composes Dialog + Button + destructive variant). Bundled into @posthog/quill at build time; consumers should import from @posthog/quill instead.",
"license": "MIT",
@@ -36,7 +36,11 @@
"lucide-react": "^0.577.0"
},
"devDependencies": {
+ "@storybook/react": "catalog:",
"@tailwindcss/vite": "^4.1.17",
+ "@tanstack/react-table": "^8.21.3",
+ "@types/react": "catalog:",
+ "@types/react-dom": "catalog:",
"@vitejs/plugin-react": "^5.1.1",
"vite": "^6.3.5",
"vite-plugin-dts": "^4.5.4"
diff --git a/packages/quill/packages/components/src/data-table.stories.tsx b/packages/quill/packages/components/src/data-table.stories.tsx
new file mode 100644
index 000000000000..b023461e7b2d
--- /dev/null
+++ b/packages/quill/packages/components/src/data-table.stories.tsx
@@ -0,0 +1,147 @@
+import type { Meta, StoryObj } from '@storybook/react'
+import { type ColumnDef } from '@tanstack/react-table'
+import * as React from 'react'
+
+import { FolderPlus } from 'lucide-react'
+
+import {
+ Badge,
+ Button,
+ Empty as QuillEmpty,
+ EmptyContent,
+ EmptyDescription,
+ EmptyHeader,
+ EmptyMedia,
+ EmptyTitle,
+} from '@posthog/quill-primitives'
+
+import { DataTable } from './data-table'
+
+interface Person {
+ id: string
+ name: string
+ email: string
+ role: string
+ signups: number
+ status: 'Active' | 'Invited'
+}
+
+const people: Person[] = Array.from({ length: 8 }, (_, i) => ({
+ id: `USR-${i + 1}`,
+ name: ['Ava', 'Ben', 'Cara', 'Dan', 'Eve', 'Finn', 'Gia', 'Hugo'][i],
+ email: `${['ava', 'ben', 'cara', 'dan', 'eve', 'finn', 'gia', 'hugo'][i]}@example.com`,
+ role: i % 3 === 0 ? 'Admin' : 'Member',
+ signups: [42, 17, 88, 5, 63, 29, 71, 13][i],
+ status: i % 4 === 0 ? 'Invited' : 'Active',
+}))
+
+// Active users read as success, pending invites as warning — same semantic
+// mapping the Table primitive's Status column uses.
+function StatusBadge({ status }: { status: string }): React.ReactElement {
+ const variant = status === 'Active' ? 'success' : status === 'Invited' ? 'warning' : 'destructive'
+ return <Badge variant={variant}>{status}</Badge>
+}
+
+const columns: ColumnDef<Person>[] = [
+ {
+ accessorKey: 'name',
+ header: 'Name',
+ cell: (info) => <span className="font-medium">{info.getValue<string>()}</span>,
+ },
+ { accessorKey: 'email', header: 'Email' },
+ { accessorKey: 'role', header: 'Role' },
+ {
+ accessorKey: 'signups',
+ header: 'Signups',
+ cell: (info) => <span className="tabular-nums">{info.getValue<number>()}</span>,
+ },
+ {
+ accessorKey: 'status',
+ header: 'Status',
+ enableSorting: false,
+ cell: (info) => <StatusBadge status={info.getValue<string>()} />,
+ },
+]
+
+const meta = {
+ title: 'Components/DataTable',
+ tags: ['autodocs'],
+} satisfies Meta
+
+export default meta
+type Story = StoryObj<typeof meta>
+
+// Click a sortable header (Name, Email, Role, Signups) to toggle asc → desc → off.
+export const Default: Story = {
+ render: () => (
+ <>
+ <p className="mb-4 text-sm text-muted-foreground">
+ Built with{' '}
+ {/* eslint-disable-next-line react/forbid-elements -- plain link in a storybook demo */}
+ <a
+ className="text-primary underline"
+ href="https://tanstack.com/table/latest/docs/framework/react/guides/getting-started"
+ target="_blank"
+ rel="noreferrer"
+ >
+ TanStack Table
+ </a>{' '}
+ and quill primitives.
+ </p>
+ <DataTable columns={columns} data={people} className="max-w-2xl rounded-md border border-[var(--border)]" />
+ </>
+ ),
+}
+
+const manyPeople: Person[] = Array.from({ length: 50 }, (_, i) => ({
+ id: `USR-${i + 1}`,
+ name: `Person ${i + 1}`,
+ email: `person${i + 1}@example.com`,
+ role: i % 3 === 0 ? 'Admin' : 'Member',
+ signups: (i * 37) % 100,
+ status: i % 4 === 0 ? 'Invited' : 'Active',
+}))
+
+export const StickyHeader: Story = {
+ render: () => (
+ <DataTable
+ columns={columns}
+ data={manyPeople}
+ stickyHeader
+ className="h-72 max-w-2xl rounded-md border border-[var(--border)]"
+ />
+ ),
+}
+
+// Default empty state — minimal and generic.
+export const Empty: Story = {
+ render: () => (
+ <DataTable columns={columns} data={[]} className="max-w-2xl rounded-md border border-[var(--border)]" />
+ ),
+}
+
+// Override the empty slot with app-specific copy and actions.
+export const EmptyCustom: Story = {
+ render: () => (
+ <DataTable
+ columns={columns}
+ data={[]}
+ className="max-w-2xl rounded-md border border-[var(--border)]"
+ empty={
+ <QuillEmpty>
+ <EmptyHeader>
+ <EmptyMedia variant="icon">
+ <FolderPlus />
+ </EmptyMedia>
+ <EmptyTitle>No projects yet</EmptyTitle>
+ <EmptyDescription>Get started by creating or importing a project.</EmptyDescription>
+ </EmptyHeader>
+ <EmptyContent className="flex-row justify-center gap-2">
+ <Button variant="primary">Create project</Button>
+ <Button variant="outline">Import</Button>
+ </EmptyContent>
+ </QuillEmpty>
+ }
+ />
+ ),
+}
diff --git a/packages/quill/packages/components/src/data-table.tsx b/packages/quill/packages/components/src/data-table.tsx
new file mode 100644
index 000000000000..d47176df6e13
--- /dev/null
+++ b/packages/quill/packages/components/src/data-table.tsx
@@ -0,0 +1,143 @@
+import {
+ type ColumnDef,
+ type SortingState,
+ flexRender,
+ getCoreRowModel,
+ getSortedRowModel,
+ useReactTable,
+} from '@tanstack/react-table'
+import { ArrowDown, ArrowUp, ChevronsUpDown, Inbox } from 'lucide-react'
+import * as React from 'react'
+
+import { Button, cn, Empty, EmptyHeader, EmptyMedia, EmptyTitle, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@posthog/quill-primitives'
+
+export interface DataTableProps<TData, TValue> {
+ columns: ColumnDef<TData, TValue>[]
+ data: TData[]
+ /** Sizing/scroll classes for the table container (forwarded to the Table primitive). */
+ className?: string
+ /** Sticky header mode, forwarded to the Table primitive. `'page'` sticks to document scroll. */
+ stickyHeader?: boolean | 'page'
+ /**
+ * Rendered in place of rows when `data` is empty. Defaults to a minimal
+ * "No results" Empty; pass a richer node (custom copy, actions) to override.
+ */
+ empty?: React.ReactNode
+}
+
+// `getIsSorted()` → ARIA sort token for the header cell.
+const ARIA_SORT = { asc: 'ascending', desc: 'descending' } as const
+
+// Minimal, generic empty state. Deliberately unopinionated — no app-specific
+// copy or action buttons; pass a richer `empty` for those. Module-level so it's
+// not re-created each render and stays out of the function signature.
+const DEFAULT_EMPTY = (
+ <Empty>
+ <EmptyHeader>
+ <EmptyMedia variant="icon">
+ <Inbox />
+ </EmptyMedia>
+ <EmptyTitle>No results</EmptyTitle>
+ </EmptyHeader>
+ </Empty>
+)
+
+/**
+ * Headless TanStack Table wired onto the quill Table primitive — client-side
+ * sorting out of the box (sortable columns render a sort button + indicator and
+ * set `aria-sort`), selection reflected via the row's `data-state`, and an empty
+ * state. Pass `enableSorting: false` on a column to opt it out.
+ */
+function DataTable<TData, TValue>({
+ columns,
+ data,
+ className,
+ stickyHeader,
+ empty = DEFAULT_EMPTY,
+}: DataTableProps<TData, TValue>): React.ReactElement {
+ const [sorting, setSorting] = React.useState<SortingState>([])
+ const table = useReactTable({
+ data,
+ columns,
+ state: { sorting },
+ onSortingChange: setSorting,
+ getCoreRowModel: getCoreRowModel(),
+ getSortedRowModel: getSortedRowModel(),
+ })
+ const rows = table.getRowModel().rows
+
+ return (
+ <Table className={className} stickyHeader={stickyHeader}>
+ <TableHeader>
+ {table.getHeaderGroups().map((headerGroup) => (
+ <TableRow key={headerGroup.id}>
+ {headerGroup.headers.map((header) => {
+ const sorted = header.column.getIsSorted()
+ const label = header.isPlaceholder
+ ? null
+ : flexRender(header.column.columnDef.header, header.getContext())
+ return (
+ <TableHead
+ key={header.id}
+ colSpan={header.colSpan}
+ aria-sort={sorted ? ARIA_SORT[sorted] : undefined}
+ >
+ {header.column.getCanSort() && !header.isPlaceholder ? (
+ <Button
+ size="sm"
+ // The Button's built-in selected styling (fill-selected, with
+ // hover preserved via its own :not(:hover) rule) marks the
+ // active sort. Real semantics live in aria-sort on the <th>.
+ aria-selected={sorted ? true : undefined}
+ className={cn(
+ "gap-1.5",
+ sorted && 'text-foreground',
+ !sorted && 'hover:bg-fill-hover/50',
+ )}
+ onClick={header.column.getToggleSortingHandler()}
+ >
+ {label}
+ {sorted === 'asc' ? (
+ <ArrowUp className="size-3" />
+ ) : sorted === 'desc' ? (
+ <ArrowDown className="size-3" />
+ ) : (
+ <ChevronsUpDown className="size-3 opacity-50" />
+ )}
+ </Button>
+ ) : (
+ label
+ )}
+ </TableHead>
+ )
+ })}
+ </TableRow>
+ ))}
+ </TableHeader>
+ <TableBody>
+ {rows.length ? (
+ rows.map((row) => (
+ <TableRow key={row.id} data-state={row.getIsSelected() ? 'selected' : undefined}>
+ {row.getVisibleCells().map((cell) => (
+ <TableCell key={cell.id}>
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
+ </TableCell>
+ ))}
+ </TableRow>
+ ))
+ ) : (
+ <TableRow>
+ <TableCell
+ colSpan={columns.length}
+ className="p-2 hover:bg-transparent"
+ >
+ {empty}
+ </TableCell>
+ </TableRow>
+ )}
+ </TableBody>
+ </Table>
+ )
+}
+
+export { DataTable }
diff --git a/packages/quill/packages/components/src/date-time-picker.tsx b/packages/quill/packages/components/src/date-time-picker.tsx
index 32b4d378b07b..14372806223d 100644
--- a/packages/quill/packages/components/src/date-time-picker.tsx
+++ b/packages/quill/packages/components/src/date-time-picker.tsx
@@ -52,6 +52,22 @@ const MONTH_NAMES = [
'December',
]
+// Tailwind `lg` breakpoint — matches the `lg:` classes that switch this picker
+// between a single calendar and the side-by-side dual-calendar layout.
+const LG_QUERY = '(min-width: 64rem)'
+
+function useMediaQuery(query: string): boolean {
+ const [matches, setMatches] = React.useState(false)
+ React.useEffect(() => {
+ const mql = window.matchMedia(query)
+ const update = (): void => setMatches(mql.matches)
+ update()
+ mql.addEventListener('change', update)
+ return () => mql.removeEventListener('change', update)
+ }, [query])
+ return matches
+}
+
export interface DateTimeValue {
start: Date
end: Date
@@ -234,7 +250,7 @@ function Calendar({
<div className="flex justify-center items-center py-1 gap-1">
<Button
variant="default"
- size="icon-xs"
+ size="icon-sm"
onClick={handlePrev}
disabled={disablePrev}
aria-label="Previous month"
@@ -264,7 +280,7 @@ function Calendar({
</Select>
<Button
variant="default"
- size="icon-xs"
+ size="icon-sm"
onClick={handleNext}
disabled={disableNext}
aria-label="Next month"
@@ -472,6 +488,10 @@ export function DateTimePicker({
}: DateTimePickerProps): React.ReactElement {
const maxDate = maxDateProp ?? new Date()
const hasExplicitMaxDate = maxDateProp !== undefined
+ // The second calendar only renders at `lg`; below it (and in compact) there's
+ // a single calendar, so the "can't pick the sibling's month" constraint shouldn't apply.
+ const isLargeScreen = useMediaQuery(LG_QUERY)
+ const twoCalendars = !compact && isLargeScreen
const [start, setStart] = React.useState<Date>(value.start)
const [end, setEnd] = React.useState<Date>(value.end)
const [range, setRange] = React.useState<DateTimeRange>(value.range)
@@ -507,6 +527,21 @@ export function DateTimePicker({
setRange(CUSTOM_RANGE)
}
+ // Move the visible calendar(s) so an edited date stays in view. With two
+ // calendars, start drives the left and end the right; with one, the single
+ // (right) calendar follows whichever edge changed.
+ const revealStart = (date: Date): void => {
+ const month = new Date(getYear(date), getMonth(date), 1)
+ if (twoCalendars) {
+ setLeftViewing(month)
+ } else {
+ setRightViewing(month)
+ }
+ }
+ const revealEnd = (date: Date): void => {
+ setRightViewing(new Date(getYear(date), getMonth(date), 1))
+ }
+
const handleStartChange = (next: Date): void => {
if (start.getTime() === next.getTime()) {
return
@@ -516,8 +551,10 @@ export function DateTimePicker({
if (next.getTime() > end.getTime()) {
setStart(end)
setEnd(next)
+ revealEnd(next)
} else {
setStart(next)
+ revealStart(next)
}
}
@@ -530,8 +567,10 @@ export function DateTimePicker({
if (next.getTime() < start.getTime()) {
setEnd(start)
setStart(next)
+ revealStart(next)
} else {
setEnd(next)
+ revealEnd(next)
}
}
@@ -542,6 +581,7 @@ export function DateTimePicker({
}
setEnd(now)
setLastSet('end')
+ revealEnd(now)
}
const handleQuickRange = (next: DateTimeRange): void => {
@@ -653,7 +693,7 @@ export function DateTimePicker({
maxDate={maxDate}
onSelect={handleSelect}
onViewChange={setRightViewing}
- siblingViewing={compact ? undefined : leftViewing}
+ siblingViewing={twoCalendars ? leftViewing : undefined}
weekStartsOn={weekStartsOn}
/>
</div>
diff --git a/packages/quill/packages/components/src/index.ts b/packages/quill/packages/components/src/index.ts
index 3403511b4124..9e390aedb3a8 100644
--- a/packages/quill/packages/components/src/index.ts
+++ b/packages/quill/packages/components/src/index.ts
@@ -8,6 +8,7 @@
// top of Table primitives. Opinionated wrappers you'd otherwise hand-roll
// in every app.
+export { DataTable, type DataTableProps } from './data-table'
export { DateTimePicker, type DateTimePickerProps, type DateTimeValue, type DateFormatOrder } from './date-time-picker'
export { quickRanges, CUSTOM_RANGE, type DateTimeRange, type DateTimeRangeName } from './date-time-ranges'
export { useCalendar, Day, Month, type UseCalendarOptions, type UseCalendarReturn } from './use-calendar'
diff --git a/packages/quill/packages/primitives/package.json b/packages/quill/packages/primitives/package.json
index 2c5d360e37e7..887d0c7d3a60 100644
--- a/packages/quill/packages/primitives/package.json
+++ b/packages/quill/packages/primitives/package.json
@@ -1,6 +1,6 @@
{
"name": "@posthog/quill-primitives",
- "version": "0.3.0-beta.10",
+ "version": "0.3.0-beta.12",
"private": true,
"description": "Internal workspace package (private, not published). The lowest layer of the quill design system — unstyled Base UI primitives wrapped with quill's Tailwind classes (Button, Card, Dialog, Input, Popover, Combobox, etc.). Bundled into @posthog/quill at build time; consumers should import from @posthog/quill instead.",
"license": "MIT",
diff --git a/packages/quill/packages/primitives/src/badge.css b/packages/quill/packages/primitives/src/badge.css
index 6a70a760b1ba..3dfd3a8e5982 100644
--- a/packages/quill/packages/primitives/src/badge.css
+++ b/packages/quill/packages/primitives/src/badge.css
@@ -41,7 +41,7 @@
/* Variants */
.quill-badge--variant-default {
color: var(--foreground);
- background-color: var(--muted);
+ background-color: var(--fill-hover);
}
.quill-badge--variant-info {
diff --git a/packages/quill/packages/primitives/src/index.ts b/packages/quill/packages/primitives/src/index.ts
index 47f3c2f537a4..08dda569b84d 100644
--- a/packages/quill/packages/primitives/src/index.ts
+++ b/packages/quill/packages/primitives/src/index.ts
@@ -218,6 +218,16 @@ export {
} from './toast'
export { Spinner } from './spinner'
export { Switch } from './switch'
+export {
+ Table,
+ TableHeader,
+ TableBody,
+ TableFooter,
+ TableHead,
+ TableRow,
+ TableCell,
+ TableCaption,
+} from './table'
export { Tabs, TabsContent, TabsList, TabsTrigger } from './tabs'
export { Textarea } from './textarea'
export { Toggle, toggleVariants } from './toggle'
diff --git a/packages/quill/packages/primitives/src/table.css b/packages/quill/packages/primitives/src/table.css
new file mode 100644
index 000000000000..7f07b2e8d7ad
--- /dev/null
+++ b/packages/quill/packages/primitives/src/table.css
@@ -0,0 +1,222 @@
+/* stylelint-disable selector-class-pattern -- descendant/attr selectors fall outside strict BEM */
+@layer components {
+ /* =========================================================================
+ Root — non-scrolling wrapper. Sizing (`className`: height, width, border,
+ radius) lands here; it clips the viewport and hosts the fixed edge-shadow
+ overlays (a pseudo inside the scroller would scroll away).
+ ========================================================================= */
+ .quill-table__root {
+ /* Edge-shadow colour. Black-on-near-black is invisible, so dark mode
+ needs a much stronger alpha. */
+ --tbl-edge-shadow: rgb(0 0 0 / 12%);
+
+ /* Generic viewport-edge shadows, toggled per edge below. */
+ --tbl-shadow-top: 0 0 0 0 transparent;
+ --tbl-shadow-right: 0 0 0 0 transparent;
+ --tbl-shadow-bottom: 0 0 0 0 transparent;
+ --tbl-shadow-left: 0 0 0 0 transparent;
+
+ position: relative;
+ width: 100%;
+
+ /* `clip` (not `hidden`) clips the rounded corners *without* establishing
+ a scroll container, so a `stickyHeader="page"` header can still escape
+ to the document scroll while corners stay clipped. */
+ overflow: clip;
+ }
+
+ .dark .quill-table__root {
+ --tbl-edge-shadow: rgb(0 0 0 / 55%);
+ }
+
+ /* Viewport — owns the scroll; fills the root. */
+ .quill-table__viewport {
+ width: 100%;
+ height: 100%;
+ overflow: auto;
+ }
+
+ /* Page-sticky mode: the header sticks to document scroll, so the viewport must
+ not establish a scroll container. (Root stays `overflow: clip` — it clips
+ without becoming a scroll container, so it doesn't capture the sticky.) */
+ .quill-table__root[data-page-sticky] .quill-table__viewport {
+ overflow: visible;
+ }
+
+ /* Two pseudos stack inset shadows at the four edges; ::before = start edges
+ (top/left), ::after = end edges (right/bottom). Inset so they hug the
+ viewport edge; on the root (non-scrolling) they stay put while scrolling. */
+ .quill-table__root::before,
+ .quill-table__root::after {
+ position: absolute;
+ inset: 0;
+ z-index: 4;
+ pointer-events: none;
+ content: '';
+ border-radius: inherit;
+ transition: box-shadow 0.2s ease;
+ }
+
+ .quill-table__root::before {
+ box-shadow: var(--tbl-shadow-top), var(--tbl-shadow-left);
+ }
+
+ .quill-table__root::after {
+ box-shadow: var(--tbl-shadow-right), var(--tbl-shadow-bottom);
+ }
+
+ /* Right/bottom are always generic. Left/top defer to the frozen column/header
+ shadow when one exists (it sits beside the frozen edge, not over it). */
+ .quill-table__root[data-scroll-right]:not(
+ :has(.quill-table__cell[data-sticky='right'], .quill-table__head[data-sticky='right'])
+ ) {
+ --tbl-shadow-right: inset -16px 0 16px -16px var(--tbl-edge-shadow);
+ }
+
+ .quill-table__root[data-scroll-bottom] {
+ --tbl-shadow-bottom: inset 0 -16px 16px -16px var(--tbl-edge-shadow);
+ }
+
+ .quill-table__root[data-scroll-left]:not(
+ :has(.quill-table__cell[data-sticky='left'], .quill-table__head[data-sticky='left'])
+ ) {
+ --tbl-shadow-left: inset 16px 0 16px -16px var(--tbl-edge-shadow);
+ }
+
+ .quill-table__root[data-scroll-top]:not(:has(.quill-table[data-sticky-header])) {
+ --tbl-shadow-top: inset 0 16px 16px -16px var(--tbl-edge-shadow);
+ }
+
+ .quill-table {
+ /* max-content lets the table outgrow the viewport → horizontal scroll;
+ min-width 100% keeps it filling when content is narrow. */
+ width: max-content;
+ min-width: 100%;
+ font-size: var(--text-xs, 0.75rem);
+ line-height: var(--text-xs--line-height, 1rem);
+ color: var(--foreground);
+ text-align: left;
+ caption-side: bottom;
+ border-spacing: 0;
+ border-collapse: separate;
+ }
+
+ /* =========================================================================
+ Head / body / footer rows
+ ========================================================================= */
+
+ /* Uppercase "label" header treatment: the quill Label look (500 weight, muted)
+ plus small-caps tracking. Applied at the cell so every header — text,
+ right-aligned, or an interactive button — gets it consistently. */
+ .quill-table__head {
+ height: 2.05rem;
+ padding-inline: 0.75rem;
+ font-size: var(--text-xxs, 0.625rem);
+ font-weight: 500;
+ color: var(--muted-foreground);
+ text-transform: uppercase;
+ letter-spacing: 0.05em;
+ white-space: nowrap;
+ background-color: var(--background);
+ border-bottom: 1px solid var(--border);
+ }
+
+ .quill-table__cell {
+ padding-block: 0.5rem;
+ padding-inline: 0.75rem;
+ background-color: var(--background);
+ border-bottom: 1px solid var(--border);
+ }
+
+ .quill-table__body .quill-table__row:last-child .quill-table__cell {
+ border-bottom: none;
+ }
+
+ .quill-table__row:hover .quill-table__cell {
+ background-color: color-mix(in oklab, var(--muted) 40%, var(--background));
+ }
+
+ .quill-table__row[data-state='selected'] .quill-table__cell {
+ background-color: color-mix(in oklab, var(--primary) 12%, var(--background));
+ }
+
+ .quill-table__footer .quill-table__cell {
+ font-weight: 500;
+ background-color: color-mix(in oklab, var(--muted) 30%, var(--background));
+ border-top: 1px solid var(--border);
+ border-bottom: none;
+ }
+
+ .quill-table__caption {
+ padding-top: 0.5rem;
+ color: var(--muted-foreground);
+ }
+
+ /* Interactive header: the whole label is a button. It inherits the head's
+ label typography (uppercase, tracked, muted, xxs) so it matches plain
+ headers instead of rendering at the button's own font; utilities in JSX
+ still override (e.g. the selected-sort colour). The negative inline margin
+ aligns the label with plain headers and lets the hover background bleed
+ into the cell padding without shifting layout. */
+ .quill-table__head > [data-slot='button'] {
+ margin-inline: -0.5rem;
+ font-size: inherit;
+ font-weight: inherit;
+ color: inherit;
+ text-transform: inherit;
+ letter-spacing: inherit;
+ }
+
+ /* =========================================================================
+ Sticky header + columns. Frozen edges are delineated by borders only; the
+ generic viewport-edge shadows above still signal off-screen overflow.
+ ========================================================================= */
+
+ /* --- Sticky header --- */
+ .quill-table[data-sticky-header] .quill-table__head {
+ position: sticky;
+ top: var(--quill-table-sticky-top, 0);
+ z-index: 2;
+ }
+
+ /* --- Sticky columns — sticky="left" | "right" on TableHead / TableCell.
+ Default offset 0; for a second sticky column set `left`/`right` via
+ inline style or className to clear the previous one's width. --- */
+ .quill-table__head[data-sticky],
+ .quill-table__cell[data-sticky] {
+ position: sticky;
+ z-index: 1;
+ }
+
+ .quill-table__head[data-sticky='left'],
+ .quill-table__cell[data-sticky='left'] {
+ left: 0;
+ border-right: 1px solid var(--border);
+ }
+
+ .quill-table__head[data-sticky='right'],
+ .quill-table__cell[data-sticky='right'] {
+ right: 0;
+ border-left: 1px solid var(--border);
+ }
+
+ /* Divider on the inner side of a non-edge frozen column lives on the NEIGHBOUR
+ cell, not the frozen cell itself: when the column is stuck against the table
+ edge, the neighbour (and its border) scrolls under it instead of doubling up
+ with the container border. When the column is first/last there is no
+ neighbour, so nothing is drawn — the container edge is the boundary. */
+ .quill-table__cell:has(+ .quill-table__cell[data-sticky='left']),
+ .quill-table__head:has(+ .quill-table__head[data-sticky='left']) {
+ border-right: 1px solid var(--border);
+ }
+
+ .quill-table__cell[data-sticky='right'] + .quill-table__cell,
+ .quill-table__head[data-sticky='right'] + .quill-table__head {
+ border-left: 1px solid var(--border);
+ }
+
+ /* Sticky header cell that is also a sticky column must outrank both. */
+ .quill-table[data-sticky-header] .quill-table__head[data-sticky] {
+ z-index: 3;
+ }
+}
diff --git a/packages/quill/packages/primitives/src/table.stories.tsx b/packages/quill/packages/primitives/src/table.stories.tsx
new file mode 100644
index 000000000000..2aeb2c51720b
--- /dev/null
+++ b/packages/quill/packages/primitives/src/table.stories.tsx
@@ -0,0 +1,452 @@
+import type { Meta, StoryObj } from '@storybook/react'
+import { ChevronsUpDown, MoreHorizontal } from 'lucide-react'
+import * as React from 'react'
+
+import { Badge } from './badge'
+import { Button } from './button'
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from './dropdown-menu'
+import { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow } from './table'
+
+const meta = {
+ title: 'Primitives/Table',
+ component: Table,
+ tags: ['autodocs'],
+} satisfies Meta<typeof Table>
+
+export default meta
+type Story = StoryObj<typeof meta>
+
+// Maps a status string to a semantic Badge variant, shared across the Status
+// columns below. Positive states (Paid/Active) read success, in-flight states
+// (Pending/Invited) read warning, everything else (Unpaid/Refunded) destructive.
+function StatusBadge({ status }: { status: string }): React.ReactElement {
+ const variant =
+ status === 'Paid' || status === 'Active'
+ ? 'success'
+ : status === 'Pending' || status === 'Invited'
+ ? 'warning'
+ : 'destructive'
+ return <Badge variant={variant}>{status}</Badge>
+}
+
+const invoices = [
+ { invoice: 'INV001', status: 'Paid', method: 'Credit Card', amount: '$250.00' },
+ { invoice: 'INV002', status: 'Pending', method: 'PayPal', amount: '$150.00' },
+ { invoice: 'INV003', status: 'Unpaid', method: 'Bank Transfer', amount: '$350.00' },
+ { invoice: 'INV004', status: 'Paid', method: 'Credit Card', amount: '$450.00' },
+ { invoice: 'INV005', status: 'Paid', method: 'PayPal', amount: '$550.00' },
+]
+
+export const Default: Story = {
+ render: () => (
+ <Table className="max-w-2xl">
+ <TableCaption>A list of your recent invoices.</TableCaption>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Invoice</TableHead>
+ <TableHead>Status</TableHead>
+ <TableHead>Method</TableHead>
+ <TableHead className="text-right">Amount</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {invoices.map((row) => (
+ <TableRow key={row.invoice}>
+ <TableCell className="font-medium">{row.invoice}</TableCell>
+ <TableCell>
+ <StatusBadge status={row.status} />
+ </TableCell>
+ <TableCell>{row.method}</TableCell>
+ <TableCell className="text-right">{row.amount}</TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ <TableFooter>
+ <TableRow>
+ <TableCell colSpan={3}>Total</TableCell>
+ <TableCell className="text-right">$1,750.00</TableCell>
+ </TableRow>
+ </TableFooter>
+ </Table>
+ ),
+} satisfies Story
+
+export const Selectable: Story = {
+ render: () => (
+ <Table className="max-w-2xl">
+ <TableHeader>
+ <TableRow>
+ <TableHead>Invoice</TableHead>
+ <TableHead>Status</TableHead>
+ <TableHead className="text-right">Amount</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {invoices.map((row, i) => (
+ <TableRow key={row.invoice} data-state={i === 1 ? 'selected' : undefined}>
+ <TableCell className="font-medium">{row.invoice}</TableCell>
+ <TableCell>
+ <StatusBadge status={row.status} />
+ </TableCell>
+ <TableCell className="text-right">{row.amount}</TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ ),
+} satisfies Story
+
+const manyRows = Array.from({ length: 40 }, (_, i) => ({
+ id: `USR-${String(i + 1).padStart(3, '0')}`,
+ name: `Person ${i + 1}`,
+ email: `person${i + 1}@example.com`,
+ role: i % 3 === 0 ? 'Admin' : 'Member',
+ status: i % 4 === 0 ? 'Invited' : 'Active',
+}))
+
+export const StickyHeader: Story = {
+ render: () => (
+ <Table stickyHeader className="h-72 max-w-2xl rounded-md border border-[var(--border)]">
+ <TableHeader>
+ <TableRow>
+ <TableHead>ID</TableHead>
+ <TableHead>Name</TableHead>
+ <TableHead>Email</TableHead>
+ <TableHead>Role</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {manyRows.map((row) => (
+ <TableRow key={row.id}>
+ <TableCell className="font-medium">{row.id}</TableCell>
+ <TableCell>{row.name}</TableCell>
+ <TableCell>{row.email}</TableCell>
+ <TableCell>{row.role}</TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ ),
+} satisfies Story
+
+const wideColumns = [
+ 'January',
+ 'February',
+ 'March',
+ 'April',
+ 'May',
+ 'June',
+ 'July',
+ 'August',
+ 'September',
+ 'October',
+ 'November',
+ 'December',
+]
+
+export const StickyColumn: Story = {
+ render: () => (
+ <Table className="max-w-xl rounded-md border border-[var(--border)]">
+ <TableHeader>
+ <TableRow>
+ <TableHead sticky="left">Region</TableHead>
+ {wideColumns.map((q) => (
+ <TableHead key={q} className="text-right whitespace-nowrap">
+ {q}
+ </TableHead>
+ ))}
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {['North America', 'Europe', 'Asia Pacific', 'Latin America'].map((region, r) => (
+ <TableRow key={region}>
+ <TableCell sticky="left" className="font-medium whitespace-nowrap">
+ {region}
+ </TableCell>
+ {wideColumns.map((q, c) => (
+ <TableCell key={q} className="text-right">
+ ${(r + 1) * (c + 1) * 1000}
+ </TableCell>
+ ))}
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ ),
+} satisfies Story
+
+export const StickyHeaderAndFirstColumn: Story = {
+ render: () => (
+ <Table stickyHeader className="h-72 max-w-xl rounded-md border border-[var(--border)]">
+ <TableHeader>
+ <TableRow>
+ <TableHead sticky="left">User</TableHead>
+ {wideColumns.map((q) => (
+ <TableHead key={q} className="text-right whitespace-nowrap">
+ {q}
+ </TableHead>
+ ))}
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {manyRows.map((row) => (
+ <TableRow key={row.id}>
+ <TableCell sticky="left" className="font-medium whitespace-nowrap">
+ {row.name}
+ </TableCell>
+ {wideColumns.map((q, c) => (
+ <TableCell key={q} className="text-right">
+ {(c + 1) * 7}
+ </TableCell>
+ ))}
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ ),
+} satisfies Story
+
+export const StickyHeaderAndSecondColumn: Story = {
+ render: () => (
+ <Table stickyHeader className="h-72 max-w-xl rounded-md border border-[var(--border)]">
+ <TableHeader>
+ <TableRow>
+ <TableHead className="whitespace-nowrap">ID</TableHead>
+ <TableHead sticky="left" className="whitespace-nowrap">
+ User
+ </TableHead>
+ {wideColumns.map((q) => (
+ <TableHead key={q} className="text-right whitespace-nowrap">
+ {q}
+ </TableHead>
+ ))}
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {manyRows.map((row) => (
+ <TableRow key={row.id}>
+ <TableCell className="whitespace-nowrap">{row.id}</TableCell>
+ <TableCell sticky="left" className="font-medium whitespace-nowrap">
+ {row.name}
+ </TableCell>
+ {wideColumns.map((q, c) => (
+ <TableCell key={q} className="text-right">
+ {(c + 1) * 7}
+ </TableCell>
+ ))}
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ ),
+} satisfies Story
+
+// Tall table with no internal scroll — the page scrolls, and the header sticks
+// to the document. `stickyHeader="page"` drops the wrappers' scroll container so
+// stickiness escapes to the window.
+const pageRows = Array.from({ length: 60 }, (_, i) => ({
+ id: `ORD-${String(i + 1).padStart(4, '0')}`,
+ customer: `Customer ${i + 1}`,
+ total: `$${((i + 1) * 37).toLocaleString()}`,
+ status: ['Paid', 'Pending', 'Refunded'][i % 3],
+}))
+
+export const PageStickyHeader: Story = {
+ render: () => (
+ <div className="max-w-2xl">
+ <p className="mb-4 text-sm text-[var(--muted-foreground)]">
+ Scroll the page — the header sticks to the window once it reaches the top.
+ </p>
+ <Table stickyHeader="page" className="rounded-md border border-[var(--border)]">
+ <TableHeader>
+ <TableRow>
+ <TableHead>Order</TableHead>
+ <TableHead>Customer</TableHead>
+ <TableHead>Status</TableHead>
+ <TableHead className="text-right">Total</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {pageRows.map((row) => (
+ <TableRow key={row.id}>
+ <TableCell className="font-medium">{row.id}</TableCell>
+ <TableCell>{row.customer}</TableCell>
+ <TableCell>
+ <StatusBadge status={row.status} />
+ </TableCell>
+ <TableCell className="text-right">{row.total}</TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </div>
+ ),
+} satisfies Story
+
+// Any column can be frozen, not just the first. Here the 3rd column (Status)
+// is sticky="left"; scrolling right slides the Order/Customer columns under it.
+export const StickyNonFirstColumn: Story = {
+ render: () => (
+ <Table className="max-w-xl rounded-md border border-[var(--border)]">
+ <TableHeader>
+ <TableRow>
+ <TableHead className="whitespace-nowrap">Order</TableHead>
+ <TableHead className="whitespace-nowrap">Customer</TableHead>
+ <TableHead sticky="left" className="whitespace-nowrap">
+ Status
+ </TableHead>
+ {wideColumns.map((q) => (
+ <TableHead key={q} className="text-right whitespace-nowrap">
+ {q}
+ </TableHead>
+ ))}
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {pageRows.slice(0, 8).map((row, r) => (
+ <TableRow key={row.id}>
+ <TableCell className="font-medium whitespace-nowrap">{row.id}</TableCell>
+ <TableCell className="whitespace-nowrap">{row.customer}</TableCell>
+ <TableCell sticky="left" className="whitespace-nowrap">
+ <StatusBadge status={row.status} />
+ </TableCell>
+ {wideColumns.map((q, c) => (
+ <TableCell key={q} className="text-right">
+ ${(r + 1) * (c + 1) * 100}
+ </TableCell>
+ ))}
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ ),
+} satisfies Story
+
+// Interactive headers: the whole label is a quill Button (label + sort
+// icon) with normal button hover — the seam for sorting, column menus, etc. The
+// button aligns with plain headers and doesn't shift layout; the non-interactive
+// "#" header stays plain text.
+export const InteractiveHeaders: Story = {
+ render: () => (
+ <Table className="max-w-2xl rounded-md border border-[var(--border)]">
+ <TableHeader>
+ <TableRow>
+ <TableHead className="w-10">#</TableHead>
+ {(['Name', 'Email', 'Role'] as const).map((label) => (
+ <TableHead key={label}>
+ <Button size="sm" className="gap-1.5" aria-label={`Sort by ${label}`}>
+ {label}
+ <ChevronsUpDown className="size-2.5" />
+ </Button>
+ </TableHead>
+ ))}
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {manyRows.slice(0, 6).map((row, i) => (
+ <TableRow key={row.id}>
+ <TableCell className="text-[var(--muted-foreground)]">{i + 1}</TableCell>
+ <TableCell className="font-medium">{row.name}</TableCell>
+ <TableCell>{row.email}</TableCell>
+ <TableCell>{row.role}</TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ ),
+} satisfies Story
+
+// Shared dummy actions menu — an ellipsis Button that opens a quill
+// DropdownMenu. Used by both the cell- and row-action stories.
+function ActionsMenu({ label }: { label: string }): React.ReactElement {
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button
+ size="icon-xs"
+ aria-label={label}
+ // Dimmed until the row is hovered; stays full while focused or open.
+ className="opacity-30 transition-opacity group-hover/row:opacity-100 focus-visible:opacity-100 data-[popup-open]:opacity-100"
+ />
+ }
+ >
+ <MoreHorizontal />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem>Edit</DropdownMenuItem>
+ <DropdownMenuItem>Duplicate</DropdownMenuItem>
+ <DropdownMenuItem>Copy link</DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem variant="destructive">Delete</DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )
+}
+
+// Cell actions: an action button pushed to the end of a content cell with
+// `ml-auto`, opening the dummy dropdown menu.
+export const CellActions: Story = {
+ render: () => (
+ <Table className="max-w-2xl rounded-md border border-[var(--border)]">
+ <TableHeader>
+ <TableRow>
+ <TableHead>Name</TableHead>
+ <TableHead>Role</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {manyRows.slice(0, 6).map((row) => (
+ <TableRow key={row.id} className="group/row">
+ <TableCell className="font-medium">
+ <span className="flex items-center gap-2">
+ {row.name}
+ <span className="ml-auto">
+ <ActionsMenu label={`Actions for ${row.name}`} />
+ </span>
+ </span>
+ </TableCell>
+ <TableCell>{row.role}</TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ ),
+} satisfies Story
+
+// Row actions: a trailing actions column with the same dummy menu at the end of
+// each row.
+export const RowActions: Story = {
+ render: () => (
+ <Table className="max-w-2xl rounded-md border border-[var(--border)]">
+ <TableHeader>
+ <TableRow>
+ <TableHead>Name</TableHead>
+ <TableHead>Email</TableHead>
+ <TableHead>Role</TableHead>
+ <TableHead className="w-0">
+ <span className="sr-only">Actions</span>
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {manyRows.slice(0, 6).map((row) => (
+ <TableRow key={row.id} className="group/row">
+ <TableCell className="font-medium">{row.name}</TableCell>
+ <TableCell>{row.email}</TableCell>
+ <TableCell>{row.role}</TableCell>
+ <TableCell className="w-0 text-right">
+ <ActionsMenu label={`Actions for ${row.name}`} />
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ ),
+} satisfies Story
diff --git a/packages/quill/packages/primitives/src/table.tsx b/packages/quill/packages/primitives/src/table.tsx
new file mode 100644
index 000000000000..36f4682cf218
--- /dev/null
+++ b/packages/quill/packages/primitives/src/table.tsx
@@ -0,0 +1,184 @@
+import * as React from 'react'
+
+import './table.css'
+import { cn } from './lib/utils'
+
+type Sticky = 'left' | 'right'
+
+// Sets each ref (object or callback) to the same node — lets the viewport carry
+// both the internal scroll-tracking ref and a caller-supplied `viewportRef`.
+function setRefs<T>(node: T, ...refs: Array<React.Ref<T> | undefined>): void {
+ for (const ref of refs) {
+ if (typeof ref === 'function') {
+ ref(node)
+ } else if (ref) {
+ ;(ref as React.MutableRefObject<T | null>).current = node
+ }
+ }
+}
+
+// Reflects which edges of `viewport` still have hidden content as
+// `data-scroll-{top,right,bottom,left}` on `root` (the non-scrolling wrapper, so
+// edge-shadow overlays on it stay fixed while content scrolls). CSS keys the
+// frozen-header/column and generic viewport-edge shadows off these — robust
+// everywhere, unlike the `scroll-state()` container query (recent Chromium only).
+function useScrollEdges(
+ rootRef: React.RefObject<HTMLDivElement | null>,
+ viewportRef: React.RefObject<HTMLDivElement | null>
+): void {
+ React.useEffect(() => {
+ const root = rootRef.current
+ const viewport = viewportRef.current
+ if (!root || !viewport) {
+ return
+ }
+ const updateEdges = (): void => {
+ const { scrollTop, scrollLeft, scrollWidth, clientWidth, scrollHeight, clientHeight } = viewport
+ // scrollLeft is negative when scrolled from the start in RTL; abs() normalizes it.
+ const left = Math.abs(scrollLeft)
+ root.toggleAttribute('data-scroll-top', scrollTop > 0)
+ root.toggleAttribute('data-scroll-bottom', Math.ceil(scrollTop + clientHeight) < scrollHeight)
+ root.toggleAttribute('data-scroll-left', left > 0)
+ root.toggleAttribute('data-scroll-right', Math.ceil(left + clientWidth) < scrollWidth)
+ }
+ updateEdges()
+ viewport.addEventListener('scroll', updateEdges, { passive: true })
+ // Catch viewport and content size changes (rows added, columns resized).
+ const observer = new ResizeObserver(updateEdges)
+ observer.observe(viewport)
+ for (const child of Array.from(viewport.children)) {
+ observer.observe(child)
+ }
+ return () => {
+ viewport.removeEventListener('scroll', updateEdges)
+ observer.disconnect()
+ }
+ }, [rootRef, viewportRef])
+}
+
+type TableProps = React.ComponentProps<'table'> & {
+ /**
+ * `true` — header sticks within the table's own scroll viewport (needs a
+ * bounded height). `'page'` — header sticks to document scroll instead; the
+ * wrappers drop their scroll container so stickiness escapes to the page.
+ * Offset it past fixed page chrome with `--quill-table-sticky-top`.
+ */
+ stickyHeader?: boolean | 'page'
+ /** Classes for the inner `<table>`. Size/scroll go on the container via `className`. */
+ tableClassName?: string
+ /** Ref to the scrolling viewport — for scroll-to-row, virtualization, IntersectionObservers, etc. */
+ viewportRef?: React.Ref<HTMLDivElement>
+}
+
+// The forwarded ref points at the `<table>` element (consistent with `...props`,
+// which also land there). The scroll container is reached via `viewportRef`.
+const Table = React.forwardRef<HTMLTableElement, TableProps>(function Table(
+ { className, tableClassName, stickyHeader = false, viewportRef, ...props },
+ ref
+) {
+ const rootRef = React.useRef<HTMLDivElement | null>(null)
+ const innerViewportRef = React.useRef<HTMLDivElement | null>(null)
+ useScrollEdges(rootRef, innerViewportRef)
+ const setViewport = React.useCallback(
+ (node: HTMLDivElement | null): void => setRefs(node, innerViewportRef, viewportRef),
+ [viewportRef]
+ )
+ // `className` sizes the non-scrolling root (which clips + hosts the fixed edge
+ // shadows); the inner viewport owns the scroll. Sticky header/columns position
+ // against the viewport.
+ return (
+ <div
+ ref={rootRef}
+ data-quill
+ data-slot="table-container"
+ data-page-sticky={stickyHeader === 'page' ? '' : undefined}
+ className={cn('quill-table__root', className)}
+ >
+ <div ref={setViewport} data-slot="table-viewport" className="quill-table__viewport">
+ <table
+ ref={ref}
+ data-slot="table"
+ data-sticky-header={stickyHeader ? '' : undefined}
+ className={cn('quill-table', tableClassName)}
+ {...props}
+ />
+ </div>
+ </div>
+ )
+})
+
+const TableHeader = React.forwardRef<HTMLTableSectionElement, React.ComponentProps<'thead'>>(function TableHeader(
+ { className, ...props },
+ ref
+) {
+ return <thead ref={ref} data-slot="table-header" className={cn('quill-table__header', className)} {...props} />
+})
+
+const TableBody = React.forwardRef<HTMLTableSectionElement, React.ComponentProps<'tbody'>>(function TableBody(
+ { className, ...props },
+ ref
+) {
+ return <tbody ref={ref} data-slot="table-body" className={cn('quill-table__body', className)} {...props} />
+})
+
+const TableFooter = React.forwardRef<HTMLTableSectionElement, React.ComponentProps<'tfoot'>>(function TableFooter(
+ { className, ...props },
+ ref
+) {
+ return <tfoot ref={ref} data-slot="table-footer" className={cn('quill-table__footer', className)} {...props} />
+})
+
+const TableRow = React.forwardRef<HTMLTableRowElement, React.ComponentProps<'tr'>>(function TableRow(
+ { className, ...props },
+ ref
+) {
+ return <tr ref={ref} data-slot="table-row" className={cn('quill-table__row', className)} {...props} />
+})
+
+const TableHead = React.forwardRef<HTMLTableCellElement, React.ComponentProps<'th'> & { sticky?: Sticky }>(
+ // `scope="col"` by default (the common case); override to "row" for row headers.
+ function TableHead({ className, sticky, scope = 'col', ...props }, ref) {
+ return (
+ <th
+ ref={ref}
+ data-slot="table-head"
+ data-sticky={sticky}
+ scope={scope}
+ className={cn('quill-table__head', className)}
+ {...props}
+ />
+ )
+ }
+)
+
+const TableCell = React.forwardRef<HTMLTableCellElement, React.ComponentProps<'td'> & { sticky?: Sticky }>(
+ function TableCell({ className, sticky, ...props }, ref) {
+ return (
+ <td
+ ref={ref}
+ data-slot="table-cell"
+ data-sticky={sticky}
+ className={cn('quill-table__cell', className)}
+ {...props}
+ />
+ )
+ }
+)
+
+const TableCaption = React.forwardRef<HTMLTableCaptionElement, React.ComponentProps<'caption'>>(function TableCaption(
+ { className, ...props },
+ ref
+) {
+ return <caption ref={ref} data-slot="table-caption" className={cn('quill-table__caption', className)} {...props} />
+})
+
+Table.displayName = 'Table'
+TableHeader.displayName = 'TableHeader'
+TableBody.displayName = 'TableBody'
+TableFooter.displayName = 'TableFooter'
+TableRow.displayName = 'TableRow'
+TableHead.displayName = 'TableHead'
+TableCell.displayName = 'TableCell'
+TableCaption.displayName = 'TableCaption'
+
+export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption }
diff --git a/packages/quill/packages/quill/package.json b/packages/quill/packages/quill/package.json
index 790d062bd0cf..fcc3aa1bf9a4 100644
--- a/packages/quill/packages/quill/package.json
+++ b/packages/quill/packages/quill/package.json
@@ -1,6 +1,6 @@
{
"name": "@posthog/quill",
- "version": "0.3.0-beta.10",
+ "version": "0.3.0-beta.12",
"description": "PostHog's unified design system — primitives, components, and blocks designed to be compiled by the consumer's Tailwind v4.",
"license": "MIT",
"repository": {
diff --git a/packages/quill/packages/tokens/package.json b/packages/quill/packages/tokens/package.json
index 7aae8cba1d3a..4f524c299f86 100644
--- a/packages/quill/packages/tokens/package.json
+++ b/packages/quill/packages/tokens/package.json
@@ -1,6 +1,6 @@
{
"name": "@posthog/quill-tokens",
- "version": "0.3.0-beta.10",
+ "version": "0.3.0-beta.12",
"license": "MIT",
"repository": {
"type": "git",
diff --git a/packages/quill/packages/tokens/src/colors.ts b/packages/quill/packages/tokens/src/colors.ts
index ca68b58d4828..5885a7ad34b4 100644
--- a/packages/quill/packages/tokens/src/colors.ts
+++ b/packages/quill/packages/tokens/src/colors.ts
@@ -117,8 +117,10 @@ export function buildSemanticColors(): Record<string, ColorTuple> {
// ── Status (independent of theme hue) ─────────
destructive: [oklch(0.92, 0.03, 32.22), oklch(0.24, 0.03, 2.79), 'bg-destructive'],
'destructive-foreground': [
- oklch(0.59, 0.2, 23.61),
- oklch(0.6316, 0.1927, 24.53),
+ // Darkened from L=0.59 → 0.51 to clear WCAG AA (5.0:1) on the light
+ // destructive surface; the prior value sat at ~3.6:1.
+ oklch(0.51, 0.2, 23.61),
+ oklch(0.6605, 0.1821, 23.51),
'text-destructive-foreground',
],
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 083de1f82154..c44314a74714 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1902,9 +1902,21 @@ importers:
specifier: 18.3.1
version: 18.3.1([email protected])
devDependencies:
+ '@storybook/react':
+ specifier: 'catalog:'
'@tailwindcss/vite':
specifier: ^4.1.17
+ '@tanstack/react-table':
+ specifier: ^8.21.3
+ '@types/react':
+ specifier: 18.3.27
+ version: 18.3.27
+ '@types/react-dom':
+ specifier: 18.3.7
+ version: 18.3.7(@types/[email protected])
'@vitejs/plugin-react':
specifier: ^5.1.1
@@ -11758,6 +11770,17 @@ packages:
peerDependencies:
vite: ^5.2.0 || ^6 || ^7 || ^8
+ '@tanstack/[email protected]':
+ resolution: {integrity: sha512-5nNMTSETP4ykGegmVkhjcS8tTLW6Vl4axfEGQN3v0zdHYbK4UfoqfPChclTrJ4EoK9QynqAu9oUf8VEmrpZ5Ww==}
+ engines: {node: '>=12'}
+ peerDependencies:
+ react: 18.3.1
+ react-dom: 18.3.1
+
+ '@tanstack/[email protected]':
+ resolution: {integrity: sha512-ldZXEhOBb8Is7xLs01fR3YEc3DERiz5silj8tnGkFZytt1abEvl/GhUmCE0PMLaMPTa3Jk4HbKmRlHmu+gCftg==}
+ engines: {node: '>=12'}
+
'@temporalio/[email protected]':
resolution: {integrity: sha512-kKEIrHMTsANiEpDVZd+v3OT6kU20UtcvAK7iibJNzQnoZUGC7XnqdKQlBuGYBxgpJzD9ppGgskXRczW+XU5Kng==}
engines: {node: '>= 20.0.0'}
@@ -34258,7 +34281,7 @@ snapshots:
'@storybook/csf': 0.1.13
'@storybook/global': 5.0.0
'@storybook/types': 7.6.24
- '@types/qs': 6.9.18
+ '@types/qs': 6.15.1
dequal: 2.0.3
lodash: 4.18.1
memoizerific: 1.11.3
@@ -35035,6 +35058,14 @@ snapshots:
tailwindcss: 4.2.4
+ dependencies:
+ '@tanstack/table-core': 8.21.3
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
+
+ '@tanstack/[email protected]': {}
+
'@temporalio/[email protected]':
dependencies:
'@temporalio/client': 1.15.0
@@ -35866,7 +35897,7 @@ snapshots:
dependencies:
'@types/node': 22.18.8
- '@types/qs': 6.9.18
+ '@types/qs': 6.15.1
'@types/range-parser': 1.2.7
'@types/send': 0.17.4