Skip to content

feat(Table): add footer support to display column summary #4194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: v3
Choose a base branch
from

Conversation

gigor
Copy link
Contributor

@gigor gigor commented May 20, 2025

πŸ”— Linked issue

Resolves: #1025

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This change enables the display of the table footer for any column.

It checks if any column definition includes a footer key, and if so, renders a element using TanStack Table’s getFooterGroups().

A new sticky-footer prop allows the footer to be fixed in place when scrolling. Footer columns can also be pinned.

Additional CSS removes padding from empty cells, so if all columns with footers are hidden, the footer won’t appear visuallyβ€”even if it is rendered in the DOM.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@gigor gigor marked this pull request as ready for review May 20, 2025 16:40
Copy link

pkg-pr-new bot commented May 20, 2025

npm i https://pkg.pr.new/@nuxt/ui@4194

commit: 9ce2af8

@gigor
Copy link
Contributor Author

gigor commented May 27, 2025

@benjamincanac can you please have a look? I will update docs if the implementation is good enough.

@benjamincanac benjamincanac changed the title feat(table) Adds table footer to display column summary feat(Table): add footer support to display column summary May 30, 2025
@gigor
Copy link
Contributor Author

gigor commented Jun 10, 2025

@benjamincanac anything else you think needs changing?

@gigor gigor requested a review from benjamincanac June 13, 2025 09:22
@@ -25,6 +26,11 @@ export default (options: Required<ModuleOptions>) => ({
thead: 'sticky top-0 inset-x-0 bg-default/75 z-[1] backdrop-blur'
}
},
stickyFooter: {
true: {
tfoot: 'sticky bottom-0 inset-x-0 bg-default/75 z-[1] backdrop-blur'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should go inside sticky.true.tfoot!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to control sticky footer and header individually, so table could have stuck header, but not footer or vice versa. I map prop.sticky to to separate variants on lines 209-210

loading: props.loading,
loadingColor: props.loadingColor,
loadingAnimation: props.loadingAnimation
}))

const hasFooter = computed(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind explaining the logic of this? Wouldn't it be simpler with columns.value.map? πŸ€”

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Columns can be multi-leveled to create few rows of table headers or footers. For example:

const columns = [
  {
     header: 'Level 1',
     columns: [
        {
            header: 'Level 2'
        }
     ]
  }
]

This traverses the list of columns, if it finds a footer definition, it stops and returns true, if it finds sub columns, it adds them to the list it needs to check. Not sure, how to accomplish this with map considering we don't know the depth of the tree.

@gigor gigor requested a review from benjamincanac June 13, 2025 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Footer Feature to Table Component
2 participants