Skip to content

Commit 487b3e8

Browse files
committed
feat: create TableHeadRow component
1 parent 210cb9e commit 487b3e8

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

packages/ui/src/components/Table/Table.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { TableCell } from "./TableCell";
1010
import { TableContext } from "./TableContext";
1111
import { TableHead, type FlowbiteTableHeadTheme } from "./TableHead";
1212
import { TableHeadCell } from "./TableHeadCell";
13+
import { TableHeadRow } from "./TableHeadRow";
1314
import { TableRow, type FlowbiteTableRowTheme } from "./TableRow";
1415

1516
export interface FlowbiteTableTheme {
@@ -52,6 +53,7 @@ TableComponent.displayName = "Table";
5253

5354
export const Table = Object.assign(TableComponent, {
5455
Head: TableHead,
56+
HeadRow: TableHeadRow,
5557
Body: TableBody,
5658
Row: TableRow,
5759
Cell: TableCell,

packages/ui/src/components/Table/TableHead.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { TableHeadContext } from "./TableHeadContext";
1010

1111
export interface FlowbiteTableHeadTheme {
1212
base: string;
13+
row: string;
1314
cell: FlowbiteTableHeadCellTheme;
1415
}
1516

@@ -26,7 +27,7 @@ export const TableHead = forwardRef<HTMLTableSectionElement, TableHeadProps>(
2627
return (
2728
<TableHeadContext.Provider value={{ theme }}>
2829
<thead className={twMerge(theme.base, className)} ref={ref} {...props}>
29-
<tr>{children}</tr>
30+
{children}
3031
</thead>
3132
</TableHeadContext.Provider>
3233
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"use client";
2+
3+
import { forwardRef, type ComponentPropsWithRef } from "react";
4+
import { twMerge } from "tailwind-merge";
5+
import { mergeDeep } from "../../helpers/merge-deep";
6+
import type { DeepPartial } from "../../types";
7+
import { useTableContext } from "./TableContext";
8+
import type { FlowbiteTableHeadTheme } from "./TableHead";
9+
10+
export interface TableHeadRowProps extends ComponentPropsWithRef<"tr"> {
11+
theme?: DeepPartial<FlowbiteTableHeadTheme>;
12+
}
13+
14+
export const TableHeadRow = forwardRef<HTMLTableRowElement, TableHeadRowProps>(
15+
({ children, className, theme: customTheme = {}, ...props }, ref) => {
16+
const { theme: rootTheme } = useTableContext();
17+
18+
const theme = mergeDeep(rootTheme.head, customTheme);
19+
20+
return (
21+
<tr className={twMerge(theme.row, className)} ref={ref} {...props}>
22+
{children}
23+
</tr>
24+
);
25+
},
26+
);
27+
28+
TableHeadRow.displayName = "Table.HeadRow";

0 commit comments

Comments
 (0)