Skip to content

Commit 98c7b70

Browse files
committed
Customize table components
1 parent 1efe7bd commit 98c7b70

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

src/components/table/index.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as React from 'react'
2+
import { TableHead as BaseTableHead, TableCell as BaseTableCell } from '../ui/table'
3+
import { cn } from '../../lib/utils'
4+
export { Table, TableBody, TableCaption, TableFooter, TableHeader, TableRow } from '../ui/table'
5+
6+
type TableHeadProps = React.ComponentProps<typeof BaseTableHead>
7+
8+
export const TableHead = ({ className, children, ...props }: TableHeadProps) => (
9+
<BaseTableHead
10+
className={cn(
11+
'h-12 px-4 flex-1 self-stretch justify-center text-muted-foreground text-sm font-medium leading-tight',
12+
className
13+
)}
14+
{...props}
15+
>
16+
{children}
17+
</BaseTableHead>
18+
)
19+
20+
type TableCellProps = React.ComponentProps<typeof BaseTableCell>
21+
22+
export const TableCell = ({ className, children, ...props }: TableCellProps) => (
23+
<BaseTableCell
24+
className={cn(
25+
'p-4 self-stretch justify-center text-foreground text-sm font-medium leading-none',
26+
className
27+
)}
28+
{...props}
29+
>
30+
{children}
31+
</BaseTableCell>
32+
)

src/stories/Table/Table.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
TableHead,
99
TableHeader,
1010
TableRow,
11-
} from '../../components/ui/table.tsx'
11+
} from '../../components/table'
1212
import { expect, within } from 'storybook/test'
1313

1414
const meta: Meta<typeof Table> = {

0 commit comments

Comments
 (0)