question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Any way to add custom fields/buttons into toolbar?

See original GitHub issue

Is your feature request related to a problem? Please describe.

From the source code of MTableToolbar, I noticed there are only two places to include fields or actions inside toolbar. One is search field which will be rendered by renderSearch(), one is columns button and export button which will be rendered by renderDefaultActions(). Let’s say I align search field to left, then align default actions to right.

Now I want to add one more button next to search field, but seems like no any prop exposed to render it.

Describe the solution you’d like

Expose one more prop to render custom fields/buttons, which could be put next to div className={classes.spacer}.

Describe alternatives you’ve considered

Currently there are two workarounds.

  1. Use custom component to replace MTableToolbar. (I don’t prefer this, since in my app both search field and export button are being used, if I replace built-in MTableToolbar, I need to duplicate these two things into new component).

  2. Create the custom field or button I need, then give it position: absolute to manually adjust it next to search field.

Additional context

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

1reaction
Dev967commented, Apr 27, 2021

or just go crazy and use a bunch of div’s. Like that,

`<div style={{display: "flex", flexDirection: "row-reverse"}}>
    <Button color="primary" variant="outlined">Create New </Button>
    <div style={{width: "100%"}}>
          <MTableToolbar {...props} searchFieldVariant="standard" />
    </div>
 </div>`

i think you can adjust things with width. or just go with another CSS approach to position these div’s hope it helps

0reactions
kajalvcommented, Jan 29, 2021

This thread helps. Although the issue title may indicate something different, the comments do contain a working solution for this specific use case: https://github.com/mbrn/material-table/issues/830

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding Custom Buttons to a Toolbar
On the left side of the editor, double-click the name of your custom button to move it to the right. Then use the...
Read more >
Customize the Quick Access Toolbar - Microsoft Support
You can add, remove, and change the order of the commands on the Quick Access Toolbar by using the Options command. Select File...
Read more >
Google Toolbar API - Guide to Making Custom Buttons
The third way is to edit a custom button using the Google Toolbar advanced button editor, available from Settings > Options > Custom...
Read more >
How to customize toolbar buttons in AutoCAD
Solution: To add new buttons to a toolbar. At the command prompt, enter CUI to open the Customize User Interface Editor (CUI).
Read more >
Add Toolbar Button - IBM
Adding toolbar buttons · Click Default to accept the default icon shown in the window. · Click Change to customize the button appearance...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found