diff --git a/.changeset/sour-poems-agree.md b/.changeset/sour-poems-agree.md new file mode 100644 index 0000000000..291a0c45c9 --- /dev/null +++ b/.changeset/sour-poems-agree.md @@ -0,0 +1,5 @@ +--- +"@frontify/fondue-components": patch +--- + +feat(Table): add stickyBackgroundColor prop diff --git a/packages/components/src/components/Table/Table.stories.tsx b/packages/components/src/components/Table/Table.stories.tsx index 7d600e7d45..67d2f467bd 100644 --- a/packages/components/src/components/Table/Table.stories.tsx +++ b/packages/components/src/components/Table/Table.stories.tsx @@ -651,6 +651,55 @@ export const StickyAllDirections: Story = { ), }; +export const StickyWithCustomBackground: Story = { + name: 'Sticky With Custom Background Color', + args: { + stickyBackgroundColor: 'var(--color-surface-dim)', + }, + render: ({ ...args }) => ( + + + + Name + Invited by + Last seen + Initial login + Last login + Actions + + + + {[...TABLE_DATA, ...TABLE_DATA, ...TABLE_DATA].map((user, index) => ( + + +
+
+
{user.name}
+
{user.email}
+
+
+
+ {user.invited} + {user.lastSeen} + {user.initialLogin} + {user.lastLogin} + + + + + + +
+ ))} +
+
+ ), +}; + export const Interactive: Story = { render: ({ ...args }) => ( diff --git a/packages/components/src/components/Table/Table.tsx b/packages/components/src/components/Table/Table.tsx index d6872cc7f0..c618fb632e 100644 --- a/packages/components/src/components/Table/Table.tsx +++ b/packages/components/src/components/Table/Table.tsx @@ -50,6 +50,12 @@ type TableRootProps = { * @default '0px' */ gutter?: CSSProperties['borderSpacing']; + /** + * Background color used by sticky parts (header, first column, last column). + * + * Accepts any CSS color value or token (e.g., `'#000'`, `'var(--color-surface-dim)'`) + */ + stickyBackgroundColor?: CSSProperties['backgroundColor']; /** * Whether header should stick to the top when scrolling * @deprecated Use `Table.Header sticky` prop instead. For sticky columns, use `Table.Body firstColumnSticky` or `lastColumnSticky` props @@ -65,7 +71,19 @@ type TableRootProps = { Pick; export const TableRoot = forwardRef( - ({ layout = 'auto', fontSize = 'medium', gutter = '0px', sticky, noBorder = false, children, ...props }, ref) => { + ( + { + layout = 'auto', + fontSize = 'medium', + gutter = '0px', + stickyBackgroundColor, + sticky, + noBorder = false, + children, + ...props + }, + ref, + ) => { const tableRef = useRef(null); const [hasHorizontalOverflow, setHasHorizontalOverflow] = useState(false); @@ -110,10 +128,12 @@ export const TableRoot = forwardRef(