Table 9
TablesText Align LeftTableButtonsPagination

Code
relume-table9.tsx
import { Button, type ButtonProps } from "@/components/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import {
Pagination,
PaginationContent,
PaginationItem,
PaginationLink,
PaginationNext,
PaginationPrevious,
} from "@/components/ui/pagination";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import { MoreHoriz } from "relume-icons";
type ImageProps = {
src: string;
alt?: string;
};
type TableData = {
name: string;
email: string;
avatar: ImageProps;
createdDate: string;
addedDate: string;
fileSize: string;
link: string;
actions: string[];
};
type Props = {
headerTitle: string;
headerDescription: string;
buttons: ButtonProps[];
tableHeaders: string[];
tableRows: TableData[];
paginationItems: number[];
};
export type Table9Props = React.ComponentPropsWithoutRef<"section"> & Partial<Props>;
export const Table9 = (props: Table9Props) => {
const { headerTitle, headerDescription, buttons, tableHeaders, tableRows, paginationItems } = {
...Table9Defaults,
...props,
} as Props;
const tableHeaderClasses = [
"w-[302px] pr-4",
"w-[256px] pr-4",
"w-[192px] pr-4",
"w-[192px] pr-4",
"w-[128px] pr-4",
"w-[80px] pr-4 text-center",
];
return (
<section className="px-[5%] py-16 md:py-24 lg:py-28">
<div className="relative container">
<div className="flex flex-col items-start justify-between gap-4 border border-b-0 border-scheme-border p-6 sm:flex-row sm:items-center">
<div>
<h1 className="text-large mb-1 font-semibold">{headerTitle}</h1>
<p>{headerDescription}</p>
</div>
<div className="flex gap-4">
{buttons.map((buttonProps, index) => (
<Button key={index} {...buttonProps} />
))}
</div>
</div>
<Table>
<TableHeader>
<TableRow>
{tableHeaders.map((header, index) => (
<TableHead key={index} className={tableHeaderClasses[index]}>
{header}
</TableHead>
))}
</TableRow>
</TableHeader>
<TableBody>
{tableRows.map((row, rowIndex) => (
<TableRow key={rowIndex}>
<TableCell className="flex-1 font-medium">
<div className="grid grid-cols-[max-content_1fr] items-center gap-3">
<img
src={row.avatar.src}
alt={row.avatar.alt}
className="h-12 w-12 rounded-full object-cover"
/>
<div>{row.name}</div>
</div>
</TableCell>
<TableCell className="max-w-[16rem] min-w-[12rem] underline">{row.email}</TableCell>
<TableCell className="max-w-[12rem] min-w-[8rem]">{row.createdDate}</TableCell>
<TableCell className="max-w-[12rem] min-w-[8rem]">{row.addedDate}</TableCell>
<TableCell className="max-w-[6rem] min-w-[8rem]">{row.fileSize}</TableCell>
<TableCell className="text-center font-semibold">
<DropdownMenu>
<DropdownMenuTrigger>
<MoreHoriz className="size-6 text-scheme-text" />
</DropdownMenuTrigger>
<DropdownMenuContent>
{row.actions.map((action, index) => (
<DropdownMenuItem key={index}>{action}</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
<Pagination className="mt-10">
<PaginationContent>
<PaginationItem>
<PaginationPrevious href="#" size="sm" variant="secondary" />
</PaginationItem>
<PaginationItem className="hidden md:block">
{paginationItems.map((item, index) => (
<PaginationLink key={index} href="#" size="sm" variant="link" className="px-4 py-2">
{item}
</PaginationLink>
))}
</PaginationItem>
<PaginationItem>
<PaginationNext href="#" size="sm" variant="secondary" />
</PaginationItem>
</PaginationContent>
</Pagination>
</div>
</section>
);
};
export const Table9Defaults: Table9Props = {
headerTitle: "Table Header",
headerDescription: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
buttons: [
{ children: "Button", variant: "secondary", size: "sm" },
{ children: "Button", size: "sm" },
],
tableHeaders: ["File name", "Email", "Created", "Added", "Size", ""],
tableRows: [
{
name: "File name",
email: "hello@relume.io",
avatar: {
src: "https://d22po4pjz3o32e.cloudfront.net/placeholder-image-small.svg",
alt: "Relume avatar 1",
},
createdDate: "1/11/2050",
addedDate: "1/11/2050",
fileSize: "818 KB",
link: "#",
actions: ["Option One", "Option Two", "Option Three"],
},
{
name: "File name",
email: "hello@relume.io",
avatar: {
src: "https://d22po4pjz3o32e.cloudfront.net/placeholder-image-small.svg",
alt: "Relume avatar 1",
},
createdDate: "1/11/2050",
addedDate: "1/11/2050",
fileSize: "818 KB",
link: "#",
actions: ["Option One", "Option Two", "Option Three"],
},
{
name: "File name",
email: "hello@relume.io",
avatar: {
src: "https://d22po4pjz3o32e.cloudfront.net/placeholder-image-small.svg",
alt: "Relume avatar 1",
},
createdDate: "1/11/2050",
addedDate: "1/11/2050",
fileSize: "818 KB",
link: "#",
actions: ["Option One", "Option Two", "Option Three"],
},
{
name: "File name",
email: "hello@relume.io",
avatar: {
src: "https://d22po4pjz3o32e.cloudfront.net/placeholder-image-small.svg",
alt: "Relume avatar 1",
},
createdDate: "1/11/2050",
addedDate: "1/11/2050",
fileSize: "818 KB",
link: "#",
actions: ["Option One", "Option Two", "Option Three"],
},
{
name: "File name",
email: "hello@relume.io",
avatar: {
src: "https://d22po4pjz3o32e.cloudfront.net/placeholder-image-small.svg",
alt: "Relume avatar 1",
},
createdDate: "1/11/2050",
addedDate: "1/11/2050",
fileSize: "818 KB",
link: "#",
actions: ["Option One", "Option Two", "Option Three"],
},
{
name: "File name",
email: "hello@relume.io",
avatar: {
src: "https://d22po4pjz3o32e.cloudfront.net/placeholder-image-small.svg",
alt: "Relume avatar 1",
},
createdDate: "1/11/2050",
addedDate: "1/11/2050",
fileSize: "818 KB",
link: "#",
actions: ["Option One", "Option Two", "Option Three"],
},
],
paginationItems: [1, 2, 3, 4, 5],
};npm i @radix-ui/react-accordion @radix-ui/react-dropdown-menu @radix-ui/react-slot @radix-ui/react-tabs class-variance-authority@0.7.1 clsx@^2.1.1 relume-icons@1.3.0 tailwind-merge@^2.2.2


