Table
tableuiPlain HTML table primitives — `<Table>`, `<TableHeader>`, `<TableRow>`, `<TableCell>` — with the registry’s borders, padding, and tokens already applied. Use this when Data Table is too heavy.
Installation
$pnpm dlx shadcn@latest add https://uipkge.dev/r/react/table.json$npx shadcn@latest add https://uipkge.dev/r/react/table.json$yarn dlx shadcn@latest add https://uipkge.dev/r/react/table.json$bunx shadcn@latest add https://uipkge.dev/r/react/table.jsonNamed registry:
npx shadcn@latest add @uipkge-react/tableInstalls to:components/ui/table/Examples
Loading interactive previews…
Loading interactive previews…
Props
| Name | Type / Values | Default | Required |
|---|---|---|---|
densityhatches for high-density admin lists and roomy patient-facing views. | 'compact' | 'cozy' | 'comfortable' | — | optional |
containerClassNamewrapper around <Table> breaks stickiness, so size the scroller here. | string | — | optional |
npm dependencies
Used by
ab-test-variant-resultsaccess-request-workflowad-spend-roi-dashboardagent-memory-inspectorai-crm-pipeline-dashboardai-saas-command-centerairbnb-host-earningsapi-documentation-pagebackorder-split-shipment-managerbill-of-lading-viewerbilling-usage-centercap-table-ownership-summarycase-studycase-study-metric-comparisoncash-flow-treasury-dashboardcdc-replication-streamcold-chain-temp-monitorcolumn-profiling-summarycommercial-invoice-generatorcommute-reimbursement-claimscomparison-migration-pathcompensation-band-benchmarkingcompliance-sanctions-screenercompliance-soc2-readinesscontent-calendar-matrixcontractor-timesheet-approvalcron-job-schedulercrypto-wallet-portfoliocustoms-clearance-trackerdata-catalog-lineagedata-contract-governancedata-explorerdata-mesh-domain-catalogdata-quality-metricsdata-retention-policy-managerdata-tabledata-table-pagedatabase-migration-schema-diffdatabase-schema-viewerdbt-model-graphdecision-matrix-tabledelivery-proof-carddeployment-pipelinedns-record-manageremployee-pulse-survey-resultsenvironment-variables-managerfeature-flags-managerfeature-store-registryfield-inspection-managerfine-tuning-job-monitorfloor-plan-explorerfreelance-work-for-hire-contractgift-card-balance-checkerguardrails-safety-scannerimmunization-historyinfluencer-campaign-cardinsurance-eligibility-checkerintegrations-connector-statusinventory-reorder-forecastinvoices-listkafka-stream-monitorlab-results-viewerlakehouse-table-optimizerlast-mile-courier-dispatchleaflet-last-mile-courier-dispatchllm-eval-benchmark-matrixloan-calculatorloyalty-rewards-tier-hubmcp-server-registry-managermodel-token-cost-optimizermultimodal-vision-playgroundorder-management-pagepacking-slip-generatorparquet-metadata-inspectorpatient-medical-recordpayouts-management-tablepayroll-run-summaryperformance-review-matrixpersonal-finance-budgetprescription-refill-managerprice-drop-alert-cardpricingpricing-01pricing-matrix-groupedpricing-matrix-sticky-headerprivacy-data-export-portalprompt-ab-testing-comparatorpurchase-order-receivingrate-limiting-configrecruitment-candidate-pipelinereferral-program-widgetreverse-etl-sync-managerrole-matrixsafe-note-calculatorschema-drift-alert-boardsecrets-rotation-schedulerskill-assessment-radarspark-job-stage-visualizersql-query-notebookstock-transfer-managerstore-pickup-curbsidestream-processing-flink-topologystudent-gradebook-tablesubpoena-legal-hold-managersubscription-churn-analyticssynthetic-data-generatortax-summary-reporttechnical-specs-sheettenant-rent-ledgertime-tracker-timesheettrademark-patent-portfoliotraining-compliance-trackertransaction-feedtree-tabletriage-queue-dashboardusage-metering-dashboardutm-campaign-buildervendor-supplier-portalvitals-tracker-chartvulnerability-scanner-reportwarehouse-inventory-gridwave-picking-consolewebhook-testerwholesale-b2b-quick-order
Files installed (3)
components/ui/table/table.tsx5.1 kB
import * as React from 'react' import { cn } from '@/lib/utils' export interface TableProps extends React.HTMLAttributes<HTMLTableElement> { // Match DataTable's density enum so consumers can opt into the same // runtime feel without wiring DataTable. `cozy` is the canonical default // for bare tables (cells: py-2, head: h-10); the other two are escape // hatches for high-density admin lists and roomy patient-facing views. density?: 'compact' | 'cozy' | 'comfortable' // Extra classes for the scroll container div (e.g. `min-h-0 flex-1` inside a // flex column). A sticky TableHeader pins to THIS div -- an outer overflow // wrapper around <Table> breaks stickiness, so size the scroller here. containerClassName?: string } const Table = React.forwardRef<HTMLTableElement, TableProps>( ({ className, containerClassName, density, ...props }, ref) => { const densityClass = density === 'compact' ? '[&_td]:py-1.5 [&_td]:text-xs [&_th]:h-8 [&_th]:text-xs' : density === 'comfortable' ? '[&_td]:py-3 [&_th]:h-12' : // cozy is the new TableCell/TableHead baseline (py-2 / h-10) -- no override. '' return ( <div data-uipkge="" data-slot="table-container" className={cn('relative w-full overflow-auto', containerClassName)} > <table ref={ref} data-uipkge="" data-slot="table" className={cn('w-full caption-bottom text-sm', densityClass, className)} {...props} /> </div> ) }, ) Table.displayName = 'Table' const TableHeader = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>( ({ className, ...props }, ref) => ( <thead ref={ref} data-uipkge="" data-slot="table-header" className={cn('bg-muted/50 [&_tr]:border-b', className)} {...props} /> ), ) TableHeader.displayName = 'TableHeader' const TableBody = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>( ({ className, ...props }, ref) => ( <tbody ref={ref} data-uipkge="" data-slot="table-body" className={cn('[&_tr:last-child]:border-0', className)} {...props} /> ), ) TableBody.displayName = 'TableBody' const TableFooter = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>( ({ className, ...props }, ref) => ( <tfoot ref={ref} data-uipkge="" data-slot="table-footer" className={cn('bg-muted/50 border-t font-medium [&>tr]:last:border-b-0', className)} {...props} /> ), ) TableFooter.displayName = 'TableFooter' const TableRow = React.forwardRef<HTMLTableRowElement, React.HTMLAttributes<HTMLTableRowElement>>( ({ className, ...props }, ref) => ( <tr ref={ref} data-uipkge="" data-slot="table-row" className={cn( 'hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors duration-150', className, )} {...props} /> ), ) TableRow.displayName = 'TableRow' const TableHead = React.forwardRef<HTMLTableCellElement, React.ThHTMLAttributes<HTMLTableCellElement>>( ({ className, ...props }, ref) => ( <th ref={ref} data-uipkge="" data-slot="table-head" className={cn( 'text-foreground h-10 px-3 text-left align-middle text-sm font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]', className, )} {...props} /> ), ) TableHead.displayName = 'TableHead' const TableCell = React.forwardRef<HTMLTableCellElement, React.TdHTMLAttributes<HTMLTableCellElement>>( ({ className, ...props }, ref) => ( <td ref={ref} data-uipkge="" data-slot="table-cell" className={cn( 'px-3 py-2 align-middle text-sm whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]', className, )} {...props} /> ), ) TableCell.displayName = 'TableCell' const TableCaption = React.forwardRef<HTMLTableCaptionElement, React.HTMLAttributes<HTMLTableCaptionElement>>( ({ className, ...props }, ref) => ( <caption ref={ref} data-uipkge="" data-slot="table-caption" className={cn('text-muted-foreground mt-4 text-sm', className)} {...props} /> ), ) TableCaption.displayName = 'TableCaption' export interface TableEmptyProps extends React.TdHTMLAttributes<HTMLTableCellElement> { colSpan?: number } const TableEmpty = React.forwardRef<HTMLTableCellElement, TableEmptyProps>( ({ className, colSpan = 1, children, ...props }, ref) => ( <TableRow> <TableCell ref={ref} colSpan={colSpan} className={cn('text-foreground p-4 align-middle text-sm whitespace-nowrap', className)} {...props} > <div className="flex items-center justify-center py-10">{children}</div> </TableCell> </TableRow> ), ) TableEmpty.displayName = 'TableEmpty' export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, TableEmpty }components/ui/table/utils.ts0.3 kB
import type { Updater } from '@tanstack/react-table' import type { Dispatch, SetStateAction } from 'react' export function valueUpdater<T>(updaterOrValue: Updater<T>, setValue: Dispatch<SetStateAction<T>>) { setValue((old) => (typeof updaterOrValue === 'function' ? (updaterOrValue as (old: T) => T)(old) : updaterOrValue)) }components/ui/table/index.ts0.2 kB
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, TableEmpty, type TableProps, type TableEmptyProps, } from './table'
Raw manifest:https://uipkge.dev/r/react/table.json