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): pagination primitive, table cell layout + full-width (#61384)

Adam Leith61f4411e6ccc
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
index b166dc5f2bc2..a60b22b032e2 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
@@ -537,7 +537,7 @@ export function MenuFilterCombobox({
>
<SelectValue />
</SelectTrigger>
- <SelectContent align="end">
+ <SelectContent align="end" alignItemWithTrigger={false}>
<SelectGroup>
{categoryOptions.map((o) => (
<SelectItem key={o.value} value={o.value}>
diff --git a/packages/quill/packages/blocks/package.json b/packages/quill/packages/blocks/package.json
index 1f0ffedce272..b29f26688bce 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.12",
+ "version": "0.3.0-beta.13",
"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 db7326d03b38..6453a4309c42 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.12",
+ "version": "0.3.0-beta.13",
"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",
diff --git a/packages/quill/packages/components/src/data-table.stories.tsx b/packages/quill/packages/components/src/data-table.stories.tsx
index b023461e7b2d..054976386934 100644
--- a/packages/quill/packages/components/src/data-table.stories.tsx
+++ b/packages/quill/packages/components/src/data-table.stories.tsx
@@ -1,8 +1,7 @@
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 * as React from 'react'
import {
Badge,
@@ -53,6 +52,8 @@ const columns: ColumnDef<Person>[] = [
{
accessorKey: 'signups',
header: 'Signups',
+ // `meta.align` aligns the header and every body cell on the same axis.
+ meta: { align: 'right' },
cell: (info) => <span className="tabular-nums">{info.getValue<number>()}</span>,
},
{
@@ -76,8 +77,7 @@ 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 */}
+ 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"
@@ -113,6 +113,78 @@ export const StickyHeader: Story = {
),
}
+// Full-width table: `fullWidth` stretches it to the container and the Name
+// column (marked `meta: { expand: true }`) absorbs the slack while the rest stay
+// content-sized.
+const fullWidthColumns: ColumnDef<Person>[] = [
+ {
+ accessorKey: 'name',
+ header: 'Name',
+ meta: { expand: true },
+ cell: (info) => (
+ <div className="flex min-w-0 flex-col">
+ <span className="truncate font-medium">{info.getValue<string>()}</span>
+ <span className="truncate text-muted-foreground">{info.row.original.email}</span>
+ </div>
+ ),
+ },
+ { accessorKey: 'role', header: 'Role' },
+ {
+ accessorKey: 'signups',
+ header: 'Signups',
+ meta: { align: 'right' },
+ cell: (info) => <span className="tabular-nums">{info.getValue<number>()}</span>,
+ },
+ {
+ accessorKey: 'status',
+ header: 'Status',
+ enableSorting: false,
+ meta: { align: 'center' },
+ cell: (info) => <StatusBadge status={info.getValue<string>()} />,
+ },
+]
+
+export const FullWidth: Story = {
+ render: () => (
+ <DataTable
+ columns={fullWidthColumns}
+ data={people}
+ fullWidth
+ className="rounded-md border border-[var(--border)]"
+ />
+ ),
+}
+
+// Client-side pagination — pass `pageSize` to page the data and render a pager
+// below the table. `pageSizeOptions` adds a rows-per-page selector.
+export const Paginated: Story = {
+ render: () => (
+ <DataTable
+ columns={columns}
+ data={manyPeople}
+ pageSize={10}
+ pageSizeOptions={[10, 25, 50]}
+ className="max-w-2xl rounded-md border border-[var(--border)]"
+ />
+ ),
+}
+
+// Full width + pagination together — the table fills the container and the pager
+// spans the same width below it (row range and page-size selector on the left,
+// page controls on the right).
+export const FullWidthPaginated: Story = {
+ render: () => (
+ <DataTable
+ columns={fullWidthColumns}
+ data={manyPeople}
+ fullWidth
+ pageSize={10}
+ pageSizeOptions={[10, 25, 50]}
+ className="rounded-md border border-[var(--border)]"
+ />
+ ),
+}
+
// Default empty state — minimal and generic.
export const Empty: Story = {
render: () => (
diff --git a/packages/quill/packages/components/src/data-table.tsx b/packages/quill/packages/components/src/data-table.tsx
index d47176df6e13..ecd65940e9d7 100644
--- a/packages/quill/packages/components/src/data-table.tsx
+++ b/packages/quill/packages/components/src/data-table.tsx
@@ -1,15 +1,57 @@
import {
type ColumnDef,
+ type PaginationState,
+ type RowData,
type SortingState,
+ type Table as TanstackTable,
flexRender,
getCoreRowModel,
+ getPaginationRowModel,
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'
+import {
+ Button,
+ cn,
+ Empty,
+ EmptyHeader,
+ EmptyMedia,
+ EmptyTitle,
+ getPaginationRange,
+ Pagination,
+ PaginationButton,
+ PaginationContent,
+ PaginationEllipsis,
+ PaginationItem,
+ PaginationNext,
+ PaginationPrevious,
+ Select,
+ SelectContent,
+ SelectGroup,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from '@posthog/quill-primitives'
+
+// Per-column extras read off `columnDef.meta`. `align` drives intra-cell
+// alignment on both the header and its body cells; `expand` makes the column
+// soak up leftover width in a `fullWidth` table.
+declare module '@tanstack/react-table' {
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- generics are fixed by TanStack's declaration
+ interface ColumnMeta<TData extends RowData, TValue> {
+ align?: 'left' | 'center' | 'right'
+ expand?: boolean
+ }
+}
export interface DataTableProps<TData, TValue> {
columns: ColumnDef<TData, TValue>[]
@@ -18,11 +60,27 @@ export interface DataTableProps<TData, TValue> {
className?: string
/** Sticky header mode, forwarded to the Table primitive. `'page'` sticks to document scroll. */
stickyHeader?: boolean | 'page'
+ /**
+ * Stretch the table to fill its container (forwarded to the Table primitive).
+ * Mark a column with `meta: { expand: true }` to choose which one absorbs the
+ * slack.
+ */
+ fullWidth?: boolean
/**
* 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
+ /**
+ * Enables client-side pagination at this page size and renders a pager below
+ * the table. Omit for a single, un-paginated list.
+ */
+ pageSize?: number
+ /**
+ * Page-size choices shown in a selector beside the pager. Only rendered when
+ * `pageSize` is set; omit to hide the selector and keep a fixed page size.
+ */
+ pageSizeOptions?: number[]
}
// `getIsSorted()` → ARIA sort token for the header cell.
@@ -42,37 +100,130 @@ const DEFAULT_EMPTY = (
</Empty>
)
+// Pager rendered below the table: a row range summary, an optional page-size
+// selector, and first/last + sibling-window page buttons with ellipses.
+function DataTablePagination<TData>({
+ table,
+ pageSizeOptions,
+}: {
+ table: TanstackTable<TData>
+ pageSizeOptions?: number[]
+}): React.ReactElement {
+ const { pageIndex, pageSize } = table.getState().pagination
+ const pageCount = table.getPageCount()
+ const total = table.getFilteredRowModel().rows.length
+ const start = total === 0 ? 0 : pageIndex * pageSize + 1
+ const end = Math.min((pageIndex + 1) * pageSize, total)
+ const range = getPaginationRange(pageCount, pageIndex)
+
+ // px-3 matches the cells' 0.75rem inline padding so the pager lines up under
+ // the column content.
+ return (
+ <div className="flex flex-wrap items-center justify-between gap-2 px-3">
+ <div className="flex items-center gap-2 text-xs text-muted-foreground">
+ <span className="tabular-nums">
+ {start}–{end} of {total}
+ </span>
+ {pageSizeOptions?.length ? (
+ <Select value={String(pageSize)} onValueChange={(value) => table.setPageSize(Number(value))}>
+ <SelectTrigger size="sm" className="w-auto gap-1" aria-label="Rows per page">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectGroup>
+ {pageSizeOptions.map((size) => (
+ <SelectItem key={size} value={String(size)}>
+ {size} / page
+ </SelectItem>
+ ))}
+ </SelectGroup>
+ </SelectContent>
+ </Select>
+ ) : null}
+ </div>
+ <Pagination className="w-auto">
+ <PaginationContent>
+ <PaginationItem>
+ <PaginationPrevious disabled={!table.getCanPreviousPage()} onClick={() => table.previousPage()}>
+ <span className="sr-only">Previous</span>
+ </PaginationPrevious>
+ </PaginationItem>
+ {range.map((item, i) =>
+ item === 'ellipsis' ? (
+ <PaginationItem key={`ellipsis-${i}`}>
+ <PaginationEllipsis />
+ </PaginationItem>
+ ) : (
+ <PaginationItem key={item}>
+ <PaginationButton
+ isActive={item === pageIndex}
+ aria-label={`Go to page ${item + 1}`}
+ onClick={() => table.setPageIndex(item)}
+ >
+ {item + 1}
+ </PaginationButton>
+ </PaginationItem>
+ )
+ )}
+ <PaginationItem>
+ <PaginationNext disabled={!table.getCanNextPage()} onClick={() => table.nextPage()}>
+ <span className="sr-only">Next</span>
+ </PaginationNext>
+ </PaginationItem>
+ </PaginationContent>
+ </Pagination>
+ </div>
+ )
+}
+
/**
* 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.
+ * set `aria-sort`), selection reflected via the row's `data-state`, optional
+ * pagination, and an empty state. Pass `enableSorting: false` on a column to opt
+ * it out, `meta: { align }` to align a column's header and cells, or
+ * `fullWidth` + `meta: { expand: true }` to stretch one column to fill.
*/
function DataTable<TData, TValue>({
columns,
data,
className,
stickyHeader,
+ fullWidth,
empty = DEFAULT_EMPTY,
+ pageSize,
+ pageSizeOptions,
}: DataTableProps<TData, TValue>): React.ReactElement {
+ const paginated = pageSize != null
const [sorting, setSorting] = React.useState<SortingState>([])
+ const [pagination, setPagination] = React.useState<PaginationState>({ pageIndex: 0, pageSize: pageSize ?? 10 })
+ // Keep the page size in sync when the prop changes at runtime — reset to the
+ // first page so the new size applies from a consistent offset.
+ React.useEffect(() => {
+ if (pageSize != null) {
+ setPagination((prev) => ({ ...prev, pageIndex: 0, pageSize }))
+ }
+ }, [pageSize])
const table = useReactTable({
data,
columns,
- state: { sorting },
+ state: { sorting, ...(paginated ? { pagination } : {}) },
onSortingChange: setSorting,
+ ...(paginated ? { onPaginationChange: setPagination } : {}),
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
+ ...(paginated ? { getPaginationRowModel: getPaginationRowModel() } : {}),
})
const rows = table.getRowModel().rows
- return (
- <Table className={className} stickyHeader={stickyHeader}>
+ const tableElement = (
+ <Table className={className} stickyHeader={stickyHeader} fullWidth={fullWidth}>
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => {
const sorted = header.column.getIsSorted()
+ const { align, expand } = header.column.columnDef.meta ?? {}
const label = header.isPlaceholder
? null
: flexRender(header.column.columnDef.header, header.getContext())
@@ -80,6 +231,8 @@ function DataTable<TData, TValue>({
<TableHead
key={header.id}
colSpan={header.colSpan}
+ align={align}
+ expand={expand}
aria-sort={sorted ? ARIA_SORT[sorted] : undefined}
>
{header.column.getCanSort() && !header.isPlaceholder ? (
@@ -90,9 +243,9 @@ function DataTable<TData, TValue>({
// active sort. Real semantics live in aria-sort on the <th>.
aria-selected={sorted ? true : undefined}
className={cn(
- "gap-1.5",
+ 'gap-1.5',
sorted && 'text-foreground',
- !sorted && 'hover:bg-fill-hover/50',
+ !sorted && 'hover:bg-fill-hover/50'
)}
onClick={header.column.getToggleSortingHandler()}
>
@@ -119,7 +272,11 @@ function DataTable<TData, TValue>({
rows.map((row) => (
<TableRow key={row.id} data-state={row.getIsSelected() ? 'selected' : undefined}>
{row.getVisibleCells().map((cell) => (
- <TableCell key={cell.id}>
+ <TableCell
+ key={cell.id}
+ align={cell.column.columnDef.meta?.align}
+ expand={cell.column.columnDef.meta?.expand}
+ >
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</TableCell>
))}
@@ -127,10 +284,7 @@ function DataTable<TData, TValue>({
))
) : (
<TableRow>
- <TableCell
- colSpan={columns.length}
- className="p-2 hover:bg-transparent"
- >
+ <TableCell colSpan={columns.length} className="p-2 hover:bg-transparent">
{empty}
</TableCell>
</TableRow>
@@ -138,6 +292,17 @@ function DataTable<TData, TValue>({
</TableBody>
</Table>
)
+
+ if (!paginated) {
+ return tableElement
+ }
+
+ return (
+ <div className="flex flex-col gap-2">
+ {tableElement}
+ <DataTablePagination table={table} pageSizeOptions={pageSizeOptions} />
+ </div>
+ )
}
export { DataTable }
diff --git a/packages/quill/packages/primitives/AGENTS.md b/packages/quill/packages/primitives/AGENTS.md
index 1fe0abd9556c..0805cd300a74 100644
--- a/packages/quill/packages/primitives/AGENTS.md
+++ b/packages/quill/packages/primitives/AGENTS.md
@@ -580,6 +580,43 @@ Item sizes: default, sm, xs
Disable scroll shadows: `<ScrollArea scrollShadows={false}>`
+### Pagination
+
+Presentational, stateless parts — you own the page state. `getPaginationRange(pageCount, pageIndex)` returns 0-based page indices and `'ellipsis'` tokens (first/last + a sibling window) for large counts.
+
+```tsx
+const range = getPaginationRange(pageCount, pageIndex)
+;<Pagination>
+ <PaginationContent>
+ <PaginationItem>
+ <PaginationPrevious disabled={pageIndex === 0} onClick={() => setPage(pageIndex - 1)} />
+ </PaginationItem>
+ {range.map((item, i) =>
+ item === 'ellipsis' ? (
+ <PaginationItem key={`e-${i}`}>
+ <PaginationEllipsis />
+ </PaginationItem>
+ ) : (
+ <PaginationItem key={item}>
+ <PaginationButton isActive={item === pageIndex} onClick={() => setPage(item)}>
+ {item + 1}
+ </PaginationButton>
+ </PaginationItem>
+ )
+ )}
+ <PaginationItem>
+ <PaginationNext disabled={pageIndex === pageCount - 1} onClick={() => setPage(pageIndex + 1)} />
+ </PaginationItem>
+ </PaginationContent>
+</Pagination>
+```
+
+`DataTable` (quill-components) wires this onto TanStack pagination — pass `pageSize` to opt in.
+
+### Table
+
+Compose `Table > TableHeader/TableBody/TableFooter > TableRow > TableHead/TableCell`. Per-cell options on `TableHead`/`TableCell`: `sticky="left" | "right"` (frozen column), `align="left" | "center" | "right"` (horizontal), `valign="top" | "middle" | "bottom"` (vertical), `expand` (absorb leftover width). `align` also positions an inline-flex header Button. On `Table`: `stickyHeader` (or `"page"`) for a sticky header, `fullWidth` to fill the container — pair `fullWidth` with `expand` on one column to choose which one stretches.
+
### Menubar
```tsx
diff --git a/packages/quill/packages/primitives/package.json b/packages/quill/packages/primitives/package.json
index 887d0c7d3a60..5aa9592675e0 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.12",
+ "version": "0.3.0-beta.13",
"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/index.ts b/packages/quill/packages/primitives/src/index.ts
index 08dda569b84d..197e707f86ee 100644
--- a/packages/quill/packages/primitives/src/index.ts
+++ b/packages/quill/packages/primitives/src/index.ts
@@ -178,6 +178,17 @@ export {
MenubarSubTrigger,
MenubarSubContent,
} from './menubar'
+export {
+ Pagination,
+ PaginationContent,
+ PaginationItem,
+ PaginationButton,
+ PaginationPrevious,
+ PaginationNext,
+ PaginationEllipsis,
+ getPaginationRange,
+ type PaginationRangeItem,
+} from './pagination'
export { Popover, PopoverContent, PopoverTrigger } from './popover'
export {
Progress,
@@ -218,16 +229,7 @@ export {
} from './toast'
export { Spinner } from './spinner'
export { Switch } from './switch'
-export {
- Table,
- TableHeader,
- TableBody,
- TableFooter,
- TableHead,
- TableRow,
- TableCell,
- TableCaption,
-} from './table'
+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/pagination.css b/packages/quill/packages/primitives/src/pagination.css
new file mode 100644
index 000000000000..303c77edc1b9
--- /dev/null
+++ b/packages/quill/packages/primitives/src/pagination.css
@@ -0,0 +1,36 @@
+/* stylelint-disable selector-class-pattern -- BEM-ish with element/attr selectors */
+@layer components {
+ .quill-pagination {
+ display: flex;
+ justify-content: center;
+ width: 100%;
+ }
+
+ .quill-pagination__content {
+ display: flex;
+ flex-direction: row;
+ gap: 0.25rem;
+ align-items: center;
+ padding: 0;
+ margin: 0;
+ list-style: none;
+ }
+
+ .quill-pagination__item {
+ display: flex;
+ }
+
+ /* Tabular numerals keep page-number buttons from jittering width as digits change. */
+ .quill-pagination__button {
+ font-variant-numeric: tabular-nums;
+ }
+
+ .quill-pagination__ellipsis {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 1.75rem;
+ height: 1.75rem;
+ color: var(--muted-foreground);
+ }
+}
diff --git a/packages/quill/packages/primitives/src/pagination.stories.tsx b/packages/quill/packages/primitives/src/pagination.stories.tsx
new file mode 100644
index 000000000000..fe9a312e8b93
--- /dev/null
+++ b/packages/quill/packages/primitives/src/pagination.stories.tsx
@@ -0,0 +1,165 @@
+import type { Meta, StoryObj } from '@storybook/react'
+import * as React from 'react'
+
+import {
+ getPaginationRange,
+ Pagination,
+ PaginationButton,
+ PaginationContent,
+ PaginationEllipsis,
+ PaginationItem,
+ PaginationNext,
+ PaginationPrevious,
+} from './pagination'
+
+const meta = {
+ title: 'Primitives/Pagination',
+ component: Pagination,
+ tags: ['autodocs'],
+} satisfies Meta<typeof Pagination>
+
+export default meta
+type Story = StoryObj<typeof meta>
+
+// Composable parts wired to local state. `getPaginationRange` collapses large
+// page counts to first/last + a sibling window with ellipses; `siblingCount`
+// widens that window.
+function PaginationDemo({
+ pageCount,
+ initialPage = 0,
+ siblingCount,
+}: {
+ pageCount: number
+ initialPage?: number
+ siblingCount?: number
+}): React.ReactElement {
+ const [pageIndex, setPageIndex] = React.useState(initialPage)
+ const range = getPaginationRange(pageCount, pageIndex, siblingCount)
+ return (
+ <Pagination>
+ <PaginationContent>
+ <PaginationItem>
+ <PaginationPrevious
+ disabled={pageIndex === 0}
+ onClick={() => setPageIndex((i) => Math.max(0, i - 1))}
+ />
+ </PaginationItem>
+ {range.map((item, i) =>
+ item === 'ellipsis' ? (
+ <PaginationItem key={`ellipsis-${i}`}>
+ <PaginationEllipsis />
+ </PaginationItem>
+ ) : (
+ <PaginationItem key={item}>
+ <PaginationButton isActive={item === pageIndex} onClick={() => setPageIndex(item)}>
+ {item + 1}
+ </PaginationButton>
+ </PaginationItem>
+ )
+ )}
+ <PaginationItem>
+ <PaginationNext
+ disabled={pageIndex === pageCount - 1}
+ onClick={() => setPageIndex((i) => Math.min(pageCount - 1, i + 1))}
+ />
+ </PaginationItem>
+ </PaginationContent>
+ </Pagination>
+ )
+}
+
+// A handful of pages — every page fits, no ellipsis. Previous is disabled on the
+// first page.
+export const Default: Story = {
+ render: () => <PaginationDemo pageCount={5} />,
+}
+
+// One page: both arrows disabled, a single active button.
+export const SinglePage: Story = {
+ render: () => <PaginationDemo pageCount={1} />,
+}
+
+// The boundary count (siblingCount*2 + 5 = 7) still renders contiguously — one
+// more page is where ellipses start.
+export const ExactFit: Story = {
+ render: () => <PaginationDemo pageCount={7} />,
+}
+
+// Current page near the start → only a trailing ellipsis before the last page.
+export const RightEllipsis: Story = {
+ render: () => <PaginationDemo pageCount={20} initialPage={1} />,
+}
+
+// Current page in the middle of a long range → ellipses on both sides.
+export const BothEllipses: Story = {
+ render: () => <PaginationDemo pageCount={20} initialPage={9} />,
+}
+
+// Current page near the end → only a leading ellipsis after the first page.
+export const LeftEllipsis: Story = {
+ render: () => <PaginationDemo pageCount={20} initialPage={18} />,
+}
+
+// `siblingCount={2}` shows two pages either side of the current one before
+// collapsing the rest.
+export const WideSiblingWindow: Story = {
+ render: () => <PaginationDemo pageCount={20} initialPage={9} siblingCount={2} />,
+}
+
+// Compact pager — just the arrows and a page indicator, no numbered buttons.
+// `sr-only` children keep the arrows icon-only while staying labelled for ATs.
+function CompactDemo(): React.ReactElement {
+ const pageCount = 12
+ const [pageIndex, setPageIndex] = React.useState(0)
+ return (
+ <Pagination>
+ <PaginationContent>
+ <PaginationItem>
+ <PaginationPrevious disabled={pageIndex === 0} onClick={() => setPageIndex((i) => i - 1)}>
+ <span className="sr-only">Previous</span>
+ </PaginationPrevious>
+ </PaginationItem>
+ <PaginationItem>
+ <span className="px-2 text-xs text-muted-foreground tabular-nums">
+ Page {pageIndex + 1} of {pageCount}
+ </span>
+ </PaginationItem>
+ <PaginationItem>
+ <PaginationNext disabled={pageIndex === pageCount - 1} onClick={() => setPageIndex((i) => i + 1)}>
+ <span className="sr-only">Next</span>
+ </PaginationNext>
+ </PaginationItem>
+ </PaginationContent>
+ </Pagination>
+ )
+}
+
+export const Compact: Story = {
+ render: () => <CompactDemo />,
+}
+
+// Custom arrow labels via children on Previous / Next.
+function CustomLabelsDemo(): React.ReactElement {
+ const pageCount = 8
+ const [pageIndex, setPageIndex] = React.useState(0)
+ return (
+ <Pagination>
+ <PaginationContent>
+ <PaginationItem>
+ <PaginationPrevious disabled={pageIndex === 0} onClick={() => setPageIndex((i) => i - 1)}>
+ Newer
+ </PaginationPrevious>
+ </PaginationItem>
+ <PaginationItem>
+ <PaginationNext disabled={pageIndex === pageCount - 1} onClick={() => setPageIndex((i) => i + 1)}>
+ Older
+ </PaginationNext>
+ </PaginationItem>
+ </PaginationContent>
+ </Pagination>
+ )
+}
+
+export const CustomLabels: Story = {
+ render: () => <CustomLabelsDemo />,
+}
diff --git a/packages/quill/packages/primitives/src/pagination.tsx b/packages/quill/packages/primitives/src/pagination.tsx
new file mode 100644
index 000000000000..9e4541140d7f
--- /dev/null
+++ b/packages/quill/packages/primitives/src/pagination.tsx
@@ -0,0 +1,182 @@
+import './pagination.css'
+
+import { ChevronLeft, ChevronRight, MoreHorizontal } from 'lucide-react'
+import * as React from 'react'
+
+import { Button, type ButtonProps } from './button'
+import { cn } from './lib/utils'
+
+/**
+ * Presentational pagination control — composable parts (no internal state). The
+ * consumer owns page state and renders an item per page; wire `onClick`/`disabled`
+ * on the buttons. Use {@link getPaginationRange} to build a first/last + sibling
+ * window with ellipses for large page counts.
+ */
+function Pagination({ className, ...props }: React.ComponentProps<'nav'>): React.ReactElement {
+ return (
+ <nav
+ aria-label="Pagination"
+ data-quill
+ data-slot="pagination"
+ className={cn('quill-pagination', className)}
+ {...props}
+ />
+ )
+}
+
+const PaginationContent = React.forwardRef<HTMLUListElement, React.ComponentProps<'ul'>>(function PaginationContent(
+ { className, ...props },
+ ref
+) {
+ return (
+ <ul
+ ref={ref}
+ data-slot="pagination-content"
+ className={cn('quill-pagination__content', className)}
+ {...props}
+ />
+ )
+})
+
+const PaginationItem = React.forwardRef<HTMLLIElement, React.ComponentProps<'li'>>(function PaginationItem(
+ { className, ...props },
+ ref
+) {
+ return <li ref={ref} data-slot="pagination-item" className={cn('quill-pagination__item', className)} {...props} />
+})
+
+type PaginationButtonProps = ButtonProps & {
+ /** Marks the current page — sets `aria-current="page"` and the selected fill. */
+ isActive?: boolean
+}
+
+// A page button. Reuses the Button's `aria-selected` fill for the active page so
+// it matches the rest of the system; real semantics live in `aria-current`.
+const PaginationButton = React.forwardRef<HTMLButtonElement, PaginationButtonProps>(function PaginationButton(
+ { isActive, size = 'icon-sm', className, ...props },
+ ref
+) {
+ return (
+ <Button
+ ref={ref}
+ data-slot="pagination-button"
+ aria-current={isActive ? 'page' : undefined}
+ aria-selected={isActive ? true : undefined}
+ size={size}
+ className={cn('quill-pagination__button', className)}
+ {...props}
+ />
+ )
+})
+
+const PaginationPrevious = React.forwardRef<HTMLButtonElement, Omit<PaginationButtonProps, 'isActive'>>(
+ function PaginationPrevious({ className, children, ...props }, ref) {
+ return (
+ <PaginationButton
+ ref={ref}
+ aria-label="Go to previous page"
+ size="sm"
+ className={cn('gap-1 px-2', className)}
+ {...props}
+ >
+ <ChevronLeft className="size-3.5" />
+ {children ?? <span>Previous</span>}
+ </PaginationButton>
+ )
+ }
+)
+
+const PaginationNext = React.forwardRef<HTMLButtonElement, Omit<PaginationButtonProps, 'isActive'>>(
+ function PaginationNext({ className, children, ...props }, ref) {
+ return (
+ <PaginationButton
+ ref={ref}
+ aria-label="Go to next page"
+ size="sm"
+ className={cn('gap-1 px-2', className)}
+ {...props}
+ >
+ {children ?? <span>Next</span>}
+ <ChevronRight className="size-3.5" />
+ </PaginationButton>
+ )
+ }
+)
+
+function PaginationEllipsis({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
+ return (
+ <span
+ aria-hidden
+ data-slot="pagination-ellipsis"
+ className={cn('quill-pagination__ellipsis', className)}
+ {...props}
+ >
+ <MoreHorizontal className="size-3.5" />
+ <span className="sr-only">More pages</span>
+ </span>
+ )
+}
+
+type PaginationRangeItem = number | 'ellipsis'
+
+// Builds the page-number window: first + last page always shown, `siblingCount`
+// pages on each side of the current page, and an 'ellipsis' token wherever a gap
+// is collapsed. All indices are 0-based (matching TanStack's `pageIndex`); shift
+// by +1 for display. Returns the full contiguous range when it would fit anyway.
+function getPaginationRange(pageCount: number, pageIndex: number, siblingCount = 1): PaginationRangeItem[] {
+ // first, last, current, the two ellipses, and a sibling on each side.
+ const slots = siblingCount * 2 + 5
+ if (pageCount <= slots) {
+ return Array.from({ length: pageCount }, (_, i) => i)
+ }
+
+ const leftSibling = Math.max(pageIndex - siblingCount, 0)
+ const rightSibling = Math.min(pageIndex + siblingCount, pageCount - 1)
+ // Show an ellipsis only when it hides more than one page (otherwise just show the page).
+ const showLeftEllipsis = leftSibling > 2
+ const showRightEllipsis = rightSibling < pageCount - 3
+ const first = 0
+ const last = pageCount - 1
+
+ const range: PaginationRangeItem[] = [first]
+ if (showLeftEllipsis) {
+ range.push('ellipsis')
+ } else {
+ for (let i = 1; i < leftSibling; i++) {
+ range.push(i)
+ }
+ }
+ for (let i = leftSibling; i <= rightSibling; i++) {
+ if (i !== first && i !== last) {
+ range.push(i)
+ }
+ }
+ if (showRightEllipsis) {
+ range.push('ellipsis')
+ } else {
+ for (let i = rightSibling + 1; i < last; i++) {
+ range.push(i)
+ }
+ }
+ range.push(last)
+ return range
+}
+
+Pagination.displayName = 'Pagination'
+PaginationContent.displayName = 'PaginationContent'
+PaginationItem.displayName = 'PaginationItem'
+PaginationButton.displayName = 'PaginationButton'
+PaginationPrevious.displayName = 'PaginationPrevious'
+PaginationNext.displayName = 'PaginationNext'
+
+export {
+ Pagination,
+ PaginationContent,
+ PaginationItem,
+ PaginationButton,
+ PaginationPrevious,
+ PaginationNext,
+ PaginationEllipsis,
+ getPaginationRange,
+ type PaginationRangeItem,
+}
diff --git a/packages/quill/packages/primitives/src/select.css b/packages/quill/packages/primitives/src/select.css
index 9c99c7c7976e..a9b89ddca6bd 100644
--- a/packages/quill/packages/primitives/src/select.css
+++ b/packages/quill/packages/primitives/src/select.css
@@ -4,6 +4,13 @@
padding: 0.25rem;
}
+ /* Ungrouped items sit directly in the list with no group to pad them, so the
+ list takes over the group's padding. Suppressed when any group is present
+ (the group owns its own padding then). */
+ .quill-select__list:not(:has(.quill-select__group)) {
+ padding: 0.25rem;
+ }
+
.quill-select__value {
display: flex;
flex: 1 1 auto;
@@ -69,6 +76,16 @@
transform-origin: var(--transform-origin);
}
+ /* When items aren't locked to the trigger, the popup is a normal
+ dropdown — size it to its widest option (capped at the viewport)
+ instead of the (often narrow) trigger, so long labels don't clip.
+ Still never narrower than the trigger. */
+ .quill-select__content[data-align-trigger='false'] {
+ width: max-content;
+ min-width: max(8rem, var(--anchor-width));
+ max-width: var(--available-width);
+ }
+
.quill-select__content[data-starting-style],
.quill-select__content[data-ending-style] {
opacity: 0;
diff --git a/packages/quill/packages/primitives/src/select.stories.tsx b/packages/quill/packages/primitives/src/select.stories.tsx
index e2356aa2011e..fd2f21b8e7a7 100644
--- a/packages/quill/packages/primitives/src/select.stories.tsx
+++ b/packages/quill/packages/primitives/src/select.stories.tsx
@@ -74,6 +74,27 @@ export const Default: Story = {
),
} satisfies Story
+// No SelectGroup and no label — items sit straight in SelectContent. The list
+// picks up the group's padding so the items still inset from the popup edge.
+export const NoGroups: Story = {
+ render: () => (
+ <div className="max-w-48 mt-32">
+ <Select items={allItems}>
+ <SelectTrigger className="w-full max-w-48" render={<Button variant="outline" />}>
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {fruits.slice(0, 5).map((item) => (
+ <SelectItem key={item.value} value={item.value}>
+ {item.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </div>
+ ),
+} satisfies Story
+
export const GroupsAndSeparators: Story = {
render: () => (
<div className="max-w-48 mt-32">
@@ -110,12 +131,7 @@ export const MultipleSelection: Story = {
const [value, setValue] = useState<string[]>(['apple', 'blueberry', 'grapes', 'pineapple', 'watermelon'])
return (
<div className="max-w-64 mt-32">
- <Select
- multiple
- value={value}
- onValueChange={setValue}
- items={fruits}
- >
+ <Select multiple value={value} onValueChange={setValue} items={fruits}>
<SelectTrigger className="w-full max-w-64" render={<Button variant="outline" />}>
<SelectValue placeholder="Select fruits..." />
</SelectTrigger>
diff --git a/packages/quill/packages/primitives/src/select.tsx b/packages/quill/packages/primitives/src/select.tsx
index 490d70a9df49..e43f2d526960 100644
--- a/packages/quill/packages/primitives/src/select.tsx
+++ b/packages/quill/packages/primitives/src/select.tsx
@@ -1,3 +1,5 @@
+import './select.css'
+
import { Select as SelectPrimitive } from '@base-ui/react/select'
import { ChevronDownIcon, ChevronUpIcon, CheckIcon } from 'lucide-react'
import * as React from 'react'
@@ -5,16 +7,19 @@ import * as React from 'react'
import { Button } from './button'
import { cn } from './lib/utils'
import { MenuLabel } from './menu-label'
-import './select.css'
const Select = SelectPrimitive.Root
function SelectGroup({ className, ...props }: SelectPrimitive.Group.Props): React.ReactElement {
- return <SelectPrimitive.Group data-slot="select-group" className={cn('quill-select__group', className)} {...props} />
+ return (
+ <SelectPrimitive.Group data-slot="select-group" className={cn('quill-select__group', className)} {...props} />
+ )
}
function SelectValue({ className, ...props }: SelectPrimitive.Value.Props): React.ReactElement {
- return <SelectPrimitive.Value data-slot="select-value" className={cn('quill-select__value', className)} {...props} />
+ return (
+ <SelectPrimitive.Value data-slot="select-value" className={cn('quill-select__value', className)} {...props} />
+ )
}
function SelectTrigger({
@@ -75,7 +80,9 @@ function SelectContent({
{...props}
>
<SelectScrollUpButton className="quill-select__scroll-button flex items-center justify-center" />
- <SelectPrimitive.List className="scroll-mask-y-4 scroll-py-4">{children}</SelectPrimitive.List>
+ <SelectPrimitive.List className="quill-select__list scroll-mask-y-4 scroll-py-4">
+ {children}
+ </SelectPrimitive.List>
<SelectScrollDownButton />
</SelectPrimitive.Popup>
</SelectPrimitive.Positioner>
@@ -84,7 +91,9 @@ function SelectContent({
}
function SelectGroupLabel({ className, ...props }: SelectPrimitive.GroupLabel.Props): React.ReactElement {
- return <SelectPrimitive.GroupLabel data-slot="select-label" className={className} render={<MenuLabel />} {...props} />
+ return (
+ <SelectPrimitive.GroupLabel data-slot="select-label" className={className} render={<MenuLabel />} {...props} />
+ )
}
function SelectItem({ className, children, ...props }: SelectPrimitive.Item.Props): React.ReactElement {
@@ -110,7 +119,13 @@ function SelectItem({ className, children, ...props }: SelectPrimitive.Item.Prop
}
function SelectSeparator({ className, ...props }: SelectPrimitive.Separator.Props): React.ReactElement {
- return <SelectPrimitive.Separator data-slot="select-separator" className={cn('quill-select__separator', className)} {...props} />
+ return (
+ <SelectPrimitive.Separator
+ data-slot="select-separator"
+ className={cn('quill-select__separator', className)}
+ {...props}
+ />
+ )
}
function SelectScrollUpButton({
@@ -121,7 +136,7 @@ function SelectScrollUpButton({
<SelectPrimitive.ScrollUpArrow
data-slot="select-scroll-up-button"
className={cn('quill-select__scroll-button quill-select__scroll-button--up', className)}
- render={<Button variant="outline" size="icon-sm"/>}
+ render={<Button variant="outline" size="icon-sm" />}
{...props}
>
<ChevronUpIcon />
@@ -137,7 +152,7 @@ function SelectScrollDownButton({
<SelectPrimitive.ScrollDownArrow
data-slot="select-scroll-down-button"
className={cn('quill-select__scroll-button quill-select__scroll-button--down', className)}
- render={<Button variant="outline" size="icon-sm"/>}
+ render={<Button variant="outline" size="icon-sm" />}
{...props}
>
<ChevronDownIcon />
diff --git a/packages/quill/packages/primitives/src/table.css b/packages/quill/packages/primitives/src/table.css
index 7f07b2e8d7ad..6f2dcb7769d4 100644
--- a/packages/quill/packages/primitives/src/table.css
+++ b/packages/quill/packages/primitives/src/table.css
@@ -101,6 +101,21 @@
border-collapse: separate;
}
+ /* Full-width: fill the container exactly (no horizontal scroll). The auto
+ layout spreads any slack across columns unless one opts in via `expand`. */
+ .quill-table[data-full-width] {
+ width: 100%;
+ }
+
+ /* The expand column claims the leftover width; siblings collapse toward their
+ content. `min-width: 0` lets the consumer truncate long content inside it
+ (add `truncate` on the cell's child). */
+ .quill-table__head[data-expand],
+ .quill-table__cell[data-expand] {
+ width: 100%;
+ min-width: 0;
+ }
+
/* =========================================================================
Head / body / footer rows
========================================================================= */
@@ -152,6 +167,42 @@
color: var(--muted-foreground);
}
+ /* =========================================================================
+ Intra-cell alignment — `align` (horizontal) / `valign` (vertical) on
+ TableHead / TableCell. Default (no attr) is left / middle. `text-align`
+ also positions an inline-flex header Button, so right-aligned interactive
+ headers push their label to the cell's end.
+ ========================================================================= */
+ .quill-table__head[data-align='left'],
+ .quill-table__cell[data-align='left'] {
+ text-align: left;
+ }
+
+ .quill-table__head[data-align='center'],
+ .quill-table__cell[data-align='center'] {
+ text-align: center;
+ }
+
+ .quill-table__head[data-align='right'],
+ .quill-table__cell[data-align='right'] {
+ text-align: right;
+ }
+
+ .quill-table__head[data-valign='top'],
+ .quill-table__cell[data-valign='top'] {
+ vertical-align: top;
+ }
+
+ .quill-table__head[data-valign='middle'],
+ .quill-table__cell[data-valign='middle'] {
+ vertical-align: middle;
+ }
+
+ .quill-table__head[data-valign='bottom'],
+ .quill-table__cell[data-valign='bottom'] {
+ vertical-align: bottom;
+ }
+
/* 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
diff --git a/packages/quill/packages/primitives/src/table.stories.tsx b/packages/quill/packages/primitives/src/table.stories.tsx
index 2aeb2c51720b..c7a29c8ff1a4 100644
--- a/packages/quill/packages/primitives/src/table.stories.tsx
+++ b/packages/quill/packages/primitives/src/table.stories.tsx
@@ -11,6 +11,7 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from './dropdown-menu'
+import { ItemContent, ItemDescription, ItemTitle } from './item'
import { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow } from './table'
const meta = {
@@ -30,8 +31,8 @@ function StatusBadge({ status }: { status: string }): React.ReactElement {
status === 'Paid' || status === 'Active'
? 'success'
: status === 'Pending' || status === 'Invited'
- ? 'warning'
- : 'destructive'
+ ? 'warning'
+ : 'destructive'
return <Badge variant={variant}>{status}</Badge>
}
@@ -77,6 +78,142 @@ export const Default: Story = {
),
} satisfies Story
+// Intra-cell alignment via the `align` (horizontal) and `valign` (vertical)
+// props on TableHead / TableCell — header and body cells share the same axis so
+// numeric columns line up. The multi-line cell shows `valign="top"`.
+export const Alignment: Story = {
+ render: () => (
+ <Table className="max-w-2xl">
+ <TableHeader>
+ <TableRow>
+ <TableHead>Invoice</TableHead>
+ <TableHead align="center">Status</TableHead>
+ <TableHead valign="top">Note</TableHead>
+ <TableHead align="right">Amount</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {invoices.map((row, i) => (
+ <TableRow key={row.invoice}>
+ <TableCell className="font-medium">{row.invoice}</TableCell>
+ <TableCell align="center">
+ <StatusBadge status={row.status} />
+ </TableCell>
+ <TableCell valign="top">
+ {i === 0 ? 'Top-aligned cell next to a taller, wrapping note column.' : row.method}
+ </TableCell>
+ <TableCell align="right" className="tabular-nums">
+ {row.amount}
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ ),
+} satisfies Story
+
+// All three CellLayout options in one table: `expand` makes the Task column
+// soak up the width (its wrapping description makes rows tall), `valign="top"`
+// keeps the short Status/Points cells aligned to that first line instead of
+// floating to the middle, `align="center"` centers the status badge, and
+// `align="right"` right-aligns the numeric points.
+const tasks = [
+ {
+ title: 'expand',
+ detail: 'This column sets `expand`, so it absorbs the table’s leftover width while Status and Points stay snug around their own content.',
+ status: 'Active',
+ points: 8,
+ },
+ {
+ title: 'valign="top"',
+ detail: 'Every cell in the row is top-aligned. This text wraps onto several lines to make the row tall, yet the badge and number stay pinned to this first line instead of floating to the middle.',
+ status: 'Pending',
+ points: 3,
+ },
+ {
+ title: 'align',
+ detail: 'Status uses `align="center"` and Points uses `align="right"` — the badge sits centered in its column and the number is pushed to the right edge.',
+ status: 'Unpaid',
+ points: 13,
+ },
+]
+
+export const CellLayout: Story = {
+ render: () => (
+ <Table fullWidth className="rounded-md border border-[var(--border)]">
+ <TableHeader>
+ <TableRow>
+ <TableHead expand>Task</TableHead>
+ <TableHead align="center">Status</TableHead>
+ <TableHead align="right">Points</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {tasks.map((row) => (
+ <TableRow key={row.title}>
+ <TableCell expand valign="top">
+ <ItemContent className="min-w-0 gap-0.5">
+ <ItemTitle className="truncate">{row.title}</ItemTitle>
+ <ItemDescription>{row.detail}</ItemDescription>
+ </ItemContent>
+ </TableCell>
+ <TableCell align="center" valign="top">
+ <StatusBadge status={row.status} />
+ </TableCell>
+ <TableCell align="right" valign="top" className="tabular-nums">
+ {row.points}
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ ),
+} satisfies Story
+
+// Full-width table: `fullWidth` stretches it to the container, and `expand` on
+// the Name column makes that column soak up the slack while the others stay
+// snug around their content. Long names truncate inside the expanding cell.
+const members = [
+ { name: 'Ava Thompson', email: '[email protected]', role: 'Admin', status: 'Active', seats: 5 },
+ { name: 'Benjamin Carter', email: '[email protected]', role: 'Member', status: 'Active', seats: 1 },
+ { name: 'Cara Mendoza-Whitfield', email: '[email protected]', role: 'Member', status: 'Invited', seats: 2 },
+ { name: 'Dan Okafor', email: '[email protected]', role: 'Billing', status: 'Active', seats: 8 },
+]
+
+export const FullWidth: Story = {
+ render: () => (
+ <Table fullWidth className="rounded-md border border-[var(--border)]">
+ <TableHeader>
+ <TableRow>
+ <TableHead expand>Member</TableHead>
+ <TableHead>Role</TableHead>
+ <TableHead align="center">Status</TableHead>
+ <TableHead align="right">Seats</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {members.map((row) => (
+ <TableRow key={row.email}>
+ <TableCell expand>
+ <ItemContent className="min-w-0">
+ <ItemTitle className="truncate">{row.name}</ItemTitle>
+ <ItemDescription className="truncate">{row.email}</ItemDescription>
+ </ItemContent>
+ </TableCell>
+ <TableCell className="whitespace-nowrap">{row.role}</TableCell>
+ <TableCell align="center">
+ <StatusBadge status={row.status} />
+ </TableCell>
+ <TableCell align="right" className="tabular-nums">
+ {row.seats}
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ ),
+} satisfies Story
+
export const Selectable: Story = {
render: () => (
<Table className="max-w-2xl">
diff --git a/packages/quill/packages/primitives/src/table.tsx b/packages/quill/packages/primitives/src/table.tsx
index 36f4682cf218..0fb6b6ff5ff2 100644
--- a/packages/quill/packages/primitives/src/table.tsx
+++ b/packages/quill/packages/primitives/src/table.tsx
@@ -1,9 +1,24 @@
+import './table.css'
+
import * as React from 'react'
-import './table.css'
import { cn } from './lib/utils'
type Sticky = 'left' | 'right'
+type Align = 'left' | 'center' | 'right'
+type VAlign = 'top' | 'middle' | 'bottom'
+
+// Per-cell layout shared by TableHead and TableCell. `align` is horizontal
+// (text-align — also positions an inline-flex header Button), `valign` vertical
+// (vertical-align). `expand` lets the column soak up leftover width in a
+// `fullWidth` table (other columns size to content). Emitted as data-attrs so
+// CSS owns the values; omit for the CSS default (left / middle).
+type CellLayout = {
+ align?: Align
+ valign?: VAlign
+ /** Absorb remaining width in a `fullWidth` table. Mark one column per table. */
+ expand?: boolean
+}
// 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`.
@@ -64,6 +79,12 @@ type TableProps = React.ComponentProps<'table'> & {
* Offset it past fixed page chrome with `--quill-table-sticky-top`.
*/
stickyHeader?: boolean | 'page'
+ /**
+ * Stretch the table to fill its container instead of sizing to content (so it
+ * never scrolls horizontally). Pair with `expand` on a column to choose which
+ * one soaks up the slack; otherwise the extra width spreads across columns.
+ */
+ fullWidth?: boolean
/** 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. */
@@ -73,7 +94,7 @@ type TableProps = React.ComponentProps<'table'> & {
// 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 },
+ { className, tableClassName, stickyHeader = false, fullWidth = false, viewportRef, ...props },
ref
) {
const rootRef = React.useRef<HTMLDivElement | null>(null)
@@ -99,6 +120,7 @@ const Table = React.forwardRef<HTMLTableElement, TableProps>(function Table(
ref={ref}
data-slot="table"
data-sticky-header={stickyHeader ? '' : undefined}
+ data-full-width={fullWidth ? '' : undefined}
className={cn('quill-table', tableClassName)}
{...props}
/>
@@ -135,14 +157,17 @@ const TableRow = React.forwardRef<HTMLTableRowElement, React.ComponentProps<'tr'
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 }>(
+const TableHead = React.forwardRef<HTMLTableCellElement, React.ComponentProps<'th'> & { sticky?: Sticky } & CellLayout>(
// `scope="col"` by default (the common case); override to "row" for row headers.
- function TableHead({ className, sticky, scope = 'col', ...props }, ref) {
+ function TableHead({ className, sticky, align, valign, expand, scope = 'col', ...props }, ref) {
return (
<th
ref={ref}
data-slot="table-head"
data-sticky={sticky}
+ data-align={align}
+ data-valign={valign}
+ data-expand={expand ? '' : undefined}
scope={scope}
className={cn('quill-table__head', className)}
{...props}
@@ -151,13 +176,16 @@ const TableHead = React.forwardRef<HTMLTableCellElement, React.ComponentProps<'t
}
)
-const TableCell = React.forwardRef<HTMLTableCellElement, React.ComponentProps<'td'> & { sticky?: Sticky }>(
- function TableCell({ className, sticky, ...props }, ref) {
+const TableCell = React.forwardRef<HTMLTableCellElement, React.ComponentProps<'td'> & { sticky?: Sticky } & CellLayout>(
+ function TableCell({ className, sticky, align, valign, expand, ...props }, ref) {
return (
<td
ref={ref}
data-slot="table-cell"
data-sticky={sticky}
+ data-align={align}
+ data-valign={valign}
+ data-expand={expand ? '' : undefined}
className={cn('quill-table__cell', className)}
{...props}
/>
diff --git a/packages/quill/packages/quill/package.json b/packages/quill/packages/quill/package.json
index fcc3aa1bf9a4..6789123015d3 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.12",
+ "version": "0.3.0-beta.13",
"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 4f524c299f86..6aa55106928c 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.12",
+ "version": "0.3.0-beta.13",
"license": "MIT",
"repository": {
"type": "git",