since3-portal/components/ui/table.tsx
2026-09-26 22:46:01 +02:00

84 lines
1.8 KiB
TypeScript

import { cn } from "cn"
function Table({ className, ...props }: React.ComponentProps<"table">) {
return (
<div data-slot="table-container" className="relative w-full overflow-auto">
<table
data-slot="table"
className={cn("w-full caption-bottom text-body", className)}
{...props}
/>
</div>
)
}
function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
return (
<thead
data-slot="table-header"
className={cn("[&_tr]:border-b [&_tr]:border-border", className)}
{...props}
/>
)
}
function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
return (
<tbody
data-slot="table-body"
className={cn("[&_tr:last-child]:border-0", className)}
{...props}
/>
)
}
function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
return (
<tr
data-slot="table-row"
className={cn(
"border-b border-border transition-colors duration-[var(--duration-fast)] ease-out hover:bg-surface",
className
)}
{...props}
/>
)
}
function TableHead({
className,
numeric,
...props
}: React.ComponentProps<"th"> & { numeric?: boolean }) {
return (
<th
data-slot="table-head"
className={cn(
"h-10 px-4 align-middle text-left text-small font-medium text-muted-foreground tracking-[0.01em]",
numeric && "text-right tabular-nums",
className
)}
{...props}
/>
)
}
function TableCell({
className,
numeric,
...props
}: React.ComponentProps<"td"> & { numeric?: boolean }) {
return (
<td
data-slot="table-cell"
className={cn(
"p-4 align-middle",
numeric && "text-right tabular-nums",
className
)}
{...props}
/>
)
}
export { Table, TableHeader, TableBody, TableRow, TableHead, TableCell }