Striped Rows Table

PreviousNext

A table with striped rows

Docs
shadcnui-blockscomponent

Preview

Loading preview…
components/customized/table/table-03.tsx
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/registry/ui/table";

const products = [
  {
    id: 101,
    name: "Wireless Headphones",
    category: "Electronics",
    price: 59.99,
    rating: 4.5,
  },
  {
    id: 102,
    name: "Yoga Mat",
    category: "Sports & Fitness",
    price: 25.0,
    rating: 4.8,
  },
  {
    id: 103,
    name: "Coffee Maker",
    category: "Home Appliances",
    price: 80.0,
    rating: 4.2,
  },
  {
    id: 104,
    name: "Running Shoes",
    category: "Sportswear",
    price: 70.0,
    rating: 4.6,
  },
  {
    id: 105,
    name: "Smartwatch",
    category: "Electronics",
    price: 120.0,
    rating: 4.7,
  },
];

export default function BorderedTableDemo() {
  return (
    <Table className="border">
      <TableHeader>
        <TableRow>
          <TableHead className="pl-4">ID</TableHead>
          <TableHead>Product Name</TableHead>
          <TableHead>Category</TableHead>
          <TableHead>Price (USD)</TableHead>
          <TableHead>Rating</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        {products.map((product) => (
          <TableRow key={product.id} className="odd:bg-muted/50">
            <TableCell className="pl-4">{product.id}</TableCell>
            <TableCell className="font-medium">{product.name}</TableCell>
            <TableCell>{product.category}</TableCell>
            <TableCell>{product.price}</TableCell>
            <TableCell>{product.rating}</TableCell>
          </TableRow>
        ))}
      </TableBody>
    </Table>
  );
}

Installation

npx shadcn@latest add @shadcnui-blocks/table-03

Usage

import { Table03 } from "@/components/table-03"
<Table03 />