Core@paxeer/core/tableimplemented
Table
shadcn Table restyled to MD3.
Install
$
pnpm exec designx add @paxeer/core/tableSource code
components/designx/core/table.tsxtsx
"use client";
import { type ComponentProps } from "react";
import { cn } from "../lib/cn";
/** Adapted from shadcn/ui Table. */
export function Table({ className, ...props }: ComponentProps<"table">) {
return (
<div data-slot="table-container" className="relative w-full overflow-x-auto">
<table
data-slot="table"
className={cn("w-full caption-bottom text-[length:var(--md-sys-typescale-body-small-size)]", className)}
{...props}
/>
</div>
);
}
export function TableHeader({ className, ...props }: ComponentProps<"thead">) {
return <thead data-slot="table-header" className={cn("[&_tr]:border-b [&_tr]:border-outline-variant", className)} {...props} />;
}
export function TableBody({ className, ...props }: ComponentProps<"tbody">) {
return <tbody data-slot="table-body" className={cn("[&_tr:last-child]:border-0", className)} {...props} />;
}
export function TableFooter({ className, ...props }: ComponentProps<"tfoot">) {
return (
<tfoot
data-slot="table-footer"
className={cn("border-t border-outline-variant bg-surface-container-low font-medium", className)}
{...props}
/>
);
}
export function TableRow({ className, ...props }: ComponentProps<"tr">) {
return (
<tr
data-slot="table-row"
className={cn(
"border-b border-outline-variant transition-colors hover:bg-surface-container-highest data-[state=selected]:bg-secondary-container",
className,
)}
{...props}
/>
);
}
export function TableHead({ className, ...props }: ComponentProps<"th">) {
return (
<th
data-slot="table-head"
className={cn(
"h-10 px-3 text-left align-middle font-medium whitespace-nowrap text-on-surface-variant",
className,
)}
{...props}
/>
);
}
export function TableCell({ className, ...props }: ComponentProps<"td">) {
return (
<td
data-slot="table-cell"
className={cn("px-3 py-2 align-middle whitespace-nowrap", className)}
{...props}
/>
);
}
export function TableCaption({ className, ...props }: ComponentProps<"caption">) {
return (
<caption
data-slot="table-caption"
className={cn("mt-4 text-[length:var(--md-sys-typescale-body-small-size)] text-on-surface-variant", className)}
{...props}
/>
);
}
Dependencies
Registry dependencies