Table
Composable responsive data table primitives with readable row states.
components/ui/table.tsx
import * as React from 'react'
import { cn } from '@/lib/utils'
export const Table = React.forwardRef<HTMLTableElement, React.HTMLAttributes<HTMLTableElement>>(({ className, ...props }, ref) => (
<div className="w-full overflow-x-auto rounded-2xl rk-border rk-shadow-sm"><table ref={ref} className={cn('w-full min-w-[560px] caption-bottom text-sm font-sans', className)} {...props} /></div>
))
Table.displayName = 'Table'
export const TableHeader = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(({ className, ...props }, ref) => <thead ref={ref} className={cn('bg-rk-ink text-left text-xs font-black uppercase tracking-wide text-rk-canvas', className)} {...props} />)
TableHeader.displayName = 'TableHeader'
export const TableBody = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(({ className, ...props }, ref) => <tbody ref={ref} className={cn('[&>tr:last-child]:border-b-0', className)} {...props} />)
TableBody.displayName = 'TableBody'
export const TableFooter = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(({ className, ...props }, ref) => <tfoot ref={ref} className={cn('border-t-2 border-black/15 bg-rk-canvas font-bold', className)} {...props} />)
TableFooter.displayName = 'TableFooter'
export const TableRow = React.forwardRef<HTMLTableRowElement, React.HTMLAttributes<HTMLTableRowElement>>(({ className, ...props }, ref) => <tr ref={ref} className={cn('border-b-2 border-black/10 transition-colors hover:bg-rk-canvas', className)} {...props} />)
TableRow.displayName = 'TableRow'
export const TableHead = React.forwardRef<HTMLTableCellElement, React.ThHTMLAttributes<HTMLTableCellElement>>(({ className, ...props }, ref) => <th ref={ref} className={cn('h-12 px-4 text-left align-middle font-mono text-[11px] font-black', className)} {...props} />)
TableHead.displayName = 'TableHead'
export const TableCell = React.forwardRef<HTMLTableCellElement, React.TdHTMLAttributes<HTMLTableCellElement>>(({ className, ...props }, ref) => <td ref={ref} className={cn('p-4 align-middle font-semibold', className)} {...props} />)
TableCell.displayName = 'TableCell'
export const TableCaption = React.forwardRef<HTMLTableCaptionElement, React.HTMLAttributes<HTMLTableCaptionElement>>(({ className, ...props }, ref) => <caption ref={ref} className={cn('mt-4 text-left text-xs font-semibold text-black/55', className)} {...props} />)
TableCaption.displayName = 'TableCaption'
- Where it goes
- statsdata-table
- Interaction
- animated-counter
- Use cases
- dashboard
DependenciesBundle weight · light
clsxtailwind-merge