Row headers
Use row headers when the first column names each row. Header cells with row and column scope let assistive technology announce both headers for every value. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.
"use client"
import {
Table,
TableBody,
TableCaption,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table"
const plans = [
{ feature: "Projects", starter: "3", team: "Unlimited", enterprise: "Unlimited" },
{ feature: "Members", starter: "1", team: "Up to 50", enterprise: "Unlimited" },
{ feature: "File history", starter: "7 days", team: "90 days", enterprise: "1 year" },
{ feature: "Single sign-on", starter: "Not included", team: "Not included", enterprise: "Included" },
]
export function TableRowHeaders() {
return (
<div className="flex w-full max-w-2xl flex-col gap-10">
<div className="w-full max-w-xl">
<Table>
<TableCaption>Plan comparison. Each row is a feature; each column is a plan.</TableCaption>
<TableHeader>
<TableRow>
<TableHead scope="col">Feature</TableHead>
<TableHead scope="col">Starter</TableHead>
<TableHead scope="col">Team</TableHead>
<TableHead scope="col">Enterprise</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{plans.map((plan) => (
<TableRow key={plan.feature}>
<TableHead scope="row" className="bg-transparent text-label-sm text-strong-950">
{plan.feature}
</TableHead>
<TableCell>{plan.starter}</TableCell>
<TableCell>{plan.team}</TableCell>
<TableCell>{plan.enterprise}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
</div>
)
}