Skip to content

[TablePagination] Slot for the left side before the spacer #45720

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

Closed
davidbielik opened this issue Mar 28, 2025 · 3 comments
Closed

[TablePagination] Slot for the left side before the spacer #45720

davidbielik opened this issue Mar 28, 2025 · 3 comments
Labels
component: TablePagination The React component.

Comments

@davidbielik
Copy link

davidbielik commented Mar 28, 2025

Summary

Is there an easier way to set text on the left side of the default TablePagination component?

I'm using this workaround, but curious if there's another way, and if not to raise this as a feature request.

<TablePagination
          slotProps={{
            spacer: {
              // Create a wrapper that includes your additional content
              component: 'div',
              style: {
                display: 'flex',
                alignItems: 'center',
              },
              children: (
                <>
                  {/* Your custom prepended text */}
                  <span style={{ marginRight: '10px', color: 'gray' }}>
                    Additional Info
                  </span>

                  {/* The original spacer will be automatically included */}
                </>
              ),
            },
          }}
          component="div"
          count={total}
          page={page}
          disabled={!total}
          onPageChange={handleChangePage}
          rowsPerPage={rowsPerPage}
          rowsPerPageOptions={[20]}
          onRowsPerPageChange={handleRowsPerPageChange}
        />
Image

Examples

No response

Motivation

No response

Search keywords: tablepagination slot left

@davidbielik davidbielik added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 28, 2025
@aarongarciah aarongarciah added the component: TablePagination The React component. label Mar 28, 2025
@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented Mar 29, 2025

@davidbielik Why do you consider this as a workaround? It's correct that you need to use the spacer slot to render a text there.

@ZeeshanTamboli ZeeshanTamboli added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 29, 2025
@davidbielik
Copy link
Author

Thanks @ZeeshanTamboli - it seemed odd to use a slot just to define children to prepend vs. using it to define the component itself. Thanks for confirming!

@github-actions github-actions bot removed the status: waiting for author Issue with insufficient information label Mar 29, 2025
Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: TablePagination The React component.
Projects
None yet
Development

No branches or pull requests

4 participants