Skip to content

[docs][ToggleButtonGroup] Add spacing demo #46058

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

Merged
merged 34 commits into from
May 22, 2025
Merged

[docs][ToggleButtonGroup] Add spacing demo #46058

merged 34 commits into from
May 22, 2025

Conversation

sai6855
Copy link
Contributor

@sai6855 sai6855 commented May 2, 2025

related to : #45569

I was hesitant to add gap prop, since this might be solved in future using css variable like how joy-ui is doing right now, so just added a demo now

preview: https://deploy-preview-46058--material-ui.netlify.app/material-ui/react-toggle-button/#spacing

@sai6855 sai6855 added docs Improvements or additions to the documentation package: material-ui Specific to @mui/material labels May 2, 2025
@mui-bot
Copy link

mui-bot commented May 2, 2025

Netlify deploy preview

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against c782ba0

@sai6855 sai6855 marked this pull request as draft May 2, 2025 10:17
@sai6855 sai6855 requested a review from siriwatknp May 2, 2025 12:04
@sai6855 sai6855 added the component: toggle button This is the name of the generic UI component, not the React module! label May 2, 2025
@sai6855 sai6855 marked this pull request as ready for review May 2, 2025 18:00
sai chand and others added 2 commits May 4, 2025 21:10
@sai6855 sai6855 requested a review from ZeeshanTamboli May 15, 2025 17:34
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

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

@sai6855 I believe we should wait for upvotes first. If there's enough demand, we should consider adding a spacing prop to ToggleButton, like in Joy UI.

@sai6855
Copy link
Contributor Author

sai6855 commented May 16, 2025

we should consider adding a spacing prop to ToggleButton,

Sure

Till the time prop is added (which we don't know when) this demo https://deploy-preview-46058--material-ui.netlify.app/material-ui/react-toggle-button/#spacing helps users how to adjust spacing between buttons, Since the solution isn’t very straightforward and the use case is common, I believe it would be helpful to include this demo to guide users.

@ZeeshanTamboli
Copy link
Member

and the use case is common

How do we know that without getting requests?

@sai6855
Copy link
Contributor Author

sai6855 commented May 17, 2025

How do we know that without getting requests?

Most of popular web apps which has millions of users has this feature, so I think we can assume use case is quite common. Attaching some of UI's i found for toggle buttons with spacing

Google sheets

image

Gmail search filter

image

Slack

image

Swiggy

Screenshot_20250516_202427_Swiggy

@ZeeshanTamboli
Copy link
Member

How do we know that without getting requests?

Most of popular web apps which has millions of users has this feature, so I think we can assume use case is quite common. Attaching some of UI's i found for toggle buttons with spacing

Google sheets

image ### Gmail search filter ![image](https://private-user-images.githubusercontent.com/60743144/444745282-b321f09e-2d0c-4075-b278-c0e2c824d44c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDc0NjkyNzEsIm5iZiI6MTc0NzQ2ODk3MSwicGF0aCI6Ii82MDc0MzE0NC80NDQ3NDUyODItYjMyMWYwOWUtMmQwYy00MDc1LWIyNzgtYzBlMmM4MjRkNDRjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTA1MTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwNTE3VDA4MDI1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTcwODI3OTU5NDUzMTc0ZjhhZTQzMmQxODFlM2FlNzMwZmRiNTc3MWVhNDNjNGExM2Y1OGJjZTIyMDgyMDkxZjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.sEMaMUOe68DFwZV2rbgi62rzigQUUd6Uiduvv34Odj4)

Slack

image

Swiggy

Screenshot_20250516_202427_Swiggy

The Google Sheets and Slack examples are shown in the Customization section of the docs. The Gmail search filter and Swiggy examples are actually tabs styled as buttons, where clicking them displays the corresponding tab content. Like this?

Also, the Customization demo already shows how to add spacing, doesn’t it?

@sai6855
Copy link
Contributor Author

sai6855 commented May 20, 2025

The Gmail search filter and Swiggy examples are actually tabs styled as buttons

No, Both in Gmail search and swiggy examples users can select multiple filters, it's possible in ToggleButtons (https://mui.com/material-ui/react-toggle-button/#multiple-selection) not in Tabs. In Tabs users can't select multiple Tabs at once.

Also, the Customization demo already shows how to add spacing, doesn’t it?

It only shows spacing when the orientation is horizontal. Adding spacing for vertical toggle buttons is still non-trivial, users need to check the source code to figure out how to override the styles correctly.

So, adding a dedicated demo that covers spacing for both orientations helps a lot.

Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

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

Alright, we can add this demo.
However, I believe we should have separate demos for horizontal and vertical orientations, rather than mixing both in one.

@ZeeshanTamboli ZeeshanTamboli changed the title [docs][material-ui][ToggleButtonGroup] Add spacing demo [docs][ToggleButtonGroup] Add spacing demo May 20, 2025
@ZeeshanTamboli ZeeshanTamboli removed the package: material-ui Specific to @mui/material label May 20, 2025
@sai6855
Copy link
Contributor Author

sai6855 commented May 21, 2025

@ZeeshanTamboli Applied your suggestions, PR is ready for review now.

preview: https://deploy-preview-46058--material-ui.netlify.app/material-ui/react-toggle-button/#spacing

@sai6855 sai6855 force-pushed the add-gap branch 3 times, most recently from 974689e to 16cb8b2 Compare May 21, 2025 12:13
@sai6855
Copy link
Contributor Author

sai6855 commented May 21, 2025

@ZeeshanTamboli any idea why test-regressions is failing?

@ZeeshanTamboli
Copy link
Member

@ZeeshanTamboli any idea why test-regressions is failing?

Let me take a look.

@sai6855 sai6855 force-pushed the add-gap branch 2 times, most recently from 0ff3f03 to 5d824ef Compare May 21, 2025 17:36
@sai6855
Copy link
Contributor Author

sai6855 commented May 21, 2025

@ZeeshanTamboli After hours of debugging 😐 , turns out accessing theme directly is causing test-regressions to fail. this commit fixed the issue 8809ddf

there several demos which do theme.vars || theme, so i guess it's fine to do that.
image

Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

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

Looks good!

@sai6855 sai6855 merged commit 2c2ede9 into mui:master May 22, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: toggle button This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants