Material-ui: [Suggestion] Provide the option to disable all padding around all elements, allow custom spacing

Created on 26 Apr 2018  路  8Comments  路  Source: mui-org/material-ui

It might be nice to provide an option to size all (or most) components so that they take up no more space than the visual element itself. This would provide an easy way to incorporate MUI components into layouts that don't necessarily follow the default spacing.

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Context

I have a simple use case. I want to override the styles of a switch so that it has no "padding" around it. By default there is a lot of space on each side of a switch. That is I want the switch element to only be the size of the switch itself. I can't seem to solve this easily (or at all) using withStyles.

Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | 1.0.0-beta.42 |
| React | 16.3.1 |

Checkbox Radio Switch enhancement

Most helpful comment

I think that we definitely need such property. We can even think of making it the default behavior in the next breaking change. Some benchmark with the switch:

  • Material-UI
    capture d ecran 2018-05-20 a 12 32 49
  • material components web
    capture d ecran 2018-05-20 a 12 30 57
  • vuetify
    capture d ecran 2018-05-20 a 12 29 22
  • react-toolbox
    capture d ecran 2018-05-20 a 12 29 06

All 8 comments

they take up no more space than the visual element itself

@AndrewMorsillo This is the approach we are trying to fallback to for all our components. I think that the issue is specific to the selection controls. I have no access to a computer as I'm writing this line. From memory, the extra space taken is a placeholder for the ripple animation.

@oliviertassinari - not at a computer either, but that鈥檚 correct. This is a dupe of a closed issue - there is no extra margin around the components beyond that needed to display them.

@mbrookes What about adding a dense mode to the SwitchBase components?

I think that we definitely need such property. We can even think of making it the default behavior in the next breaking change. Some benchmark with the switch:

  • Material-UI
    capture d ecran 2018-05-20 a 12 32 49
  • material components web
    capture d ecran 2018-05-20 a 12 30 57
  • vuetify
    capture d ecran 2018-05-20 a 12 29 22
  • react-toolbox
    capture d ecran 2018-05-20 a 12 29 06

Ah, and have the focus indicator / ripple overflow. That makes sense.

Any updates on this issue? This would be very useful for me as well.

@galenlong The situation has changed between v3 and v4. I have refactored the implementation of the component to take the spacing constraint into account.

Capture d鈥檈虂cran 2019-08-20 a虁 10 59 55

It's a step in the right direction.

I'm closing as it didn't get traction. You can remove the padding with an override. Thanks for the discussion.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cfilipov picture cfilipov  路  55Comments

HZooly picture HZooly  路  63Comments

kybarg picture kybarg  路  164Comments

iceafish picture iceafish  路  62Comments

sjstebbins picture sjstebbins  路  71Comments