Skip to content

Commit

Permalink
fix(table): tablecolumn align prop
Browse files Browse the repository at this point in the history
  • Loading branch information
chirokas committed Apr 28, 2024
1 parent 1a033fe commit fc3a150
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/rich-sloths-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@nextui-org/table": patch
"@nextui-org/theme": patch
---

Fix #2886 TableColumn align prop fixed, style improved.
4 changes: 2 additions & 2 deletions packages/components/table/src/table-column-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const TableColumnHeader = forwardRef<"th", TableColumnHeaderProps>((props, ref)

const {isFocusVisible, focusProps} = useFocusRing();
const {isHovered, hoverProps} = useHover({});
const {hideHeader, ...columnProps} = node.props;
const {hideHeader, align, ...columnProps} = node.props;

const allowsSorting = columnProps.allowsSorting;

Expand All @@ -57,7 +57,7 @@ const TableColumnHeader = forwardRef<"th", TableColumnHeaderProps>((props, ref)
allowsSorting ? hoverProps : {},
otherProps,
)}
className={slots.th?.({class: thStyles})}
className={slots.th?.({align, class: thStyles})}
>
{hideHeader ? <VisuallyHidden>{node.rendered}</VisuallyHidden> : node.rendered}
{allowsSorting && (
Expand Down
14 changes: 12 additions & 2 deletions packages/core/theme/src/components/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ const table = tv({
"group",
"px-3",
"h-10",
"text-left",
"rtl:text-right",
"align-middle",
"bg-default-100",
"whitespace-nowrap",
Expand Down Expand Up @@ -249,6 +247,17 @@ const table = tv({
table: "w-full",
},
},
align: {
start: {
th: "text-start",
},
center: {
th: "text-center",
},
end: {
th: "text-end",
},
},
},
defaultVariants: {
layout: "auto",
Expand All @@ -260,6 +269,7 @@ const table = tv({
isStriped: false,
fullWidth: true,
disableAnimation: false,
align: "start",
},
});

Expand Down

0 comments on commit fc3a150

Please sign in to comment.