Skip to content
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

[theme/styles] Unable to override MuiTableCell padding #9749

Closed
caub opened this issue Jan 5, 2018 · 7 comments
Closed

[theme/styles] Unable to override MuiTableCell padding #9749

caub opened this issue Jan 5, 2018 · 7 comments
Labels
component: table This is the name of the generic UI component, not the React module! customization: css Design CSS customizability support: question Community support but can be turned into an improvement

Comments

@caub
Copy link
Contributor

caub commented Jan 5, 2018

demo: https://codesandbox.io/s/vyj481zp05

versions: see demo

I'm doing

const theme = createMuiTheme({
  overrides: {
    MuiTableCell: {
      root: {
        padding: '40px 24px 40px 16px',
        backgroundColor: 'lightblue'
      }
    }
  }
});

but it's injected before other MuiTableCell styles, so it doesn't override

.MuiTableCell-root-37 {
  padding: 40px 24px 40px 16px;
  text-align: left;
  border-bottom: 1px solid
    rgba(235, 235, 235, 1);
  background-color: lightblue;
}
//...
.MuiTableCell-paddingDefault-40 {
  padding: 4px 56px 4px 24px;
}
@caub caub changed the title Unable to override MuiTableCell padding from theme [theme/styles] Unable to override MuiTableCell padding Jan 5, 2018
@mbrookes

This comment was marked as resolved.

@mbrookes mbrookes closed this as completed Jan 5, 2018
@mbrookes mbrookes added the support: question Community support but can be turned into an improvement label Jan 5, 2018
@caub
Copy link
Contributor Author

caub commented Jan 5, 2018

@mbrookes Thanks, well, I've been reading the whole customization, styles and API docs, and didn't find any way to do it. It's maybe not a bug, if there's an easy solution, but in any case, I'll be glad to improve doc and help, so it can belong here too I think

overrides should override styles right? so it should be placed after other styles

(edited 1st message to make it more clear)

@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 5, 2018

It could be a bug with the override mechanism, changing the key order on the object which changes the CSS specificity overall.

@oliviertassinari oliviertassinari added support: question Community support but can be turned into an improvement and removed support: question Community support but can be turned into an improvement labels Jan 5, 2018
@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 5, 2018

My bad, @mbrookes is right, there is no bug.
Just target the right CSS, you still have to account for specificity:

  overrides: {
    MuiTableCell: {
     root: {
        backgroundColor: 'lightblue'
      },
+     paddingDefault: {
+       padding: '40px 24px 40px 16px',
+     },
    },
  },

@spencerdcarlson

This comment has been minimized.

@goleary
Copy link
Contributor

goleary commented Dec 19, 2019

For anyone that ends up here trying to override the default padding of a TableCell:

It looks like the CSS class paddingDefault was removed, so you now need to override the padding in the root class of MuiTableCell as @caub does at the top of this issue.

@JeremyBernier

This comment was marked as off-topic.

@oliviertassinari oliviertassinari added component: table This is the name of the generic UI component, not the React module! customization: css Design CSS customizability labels Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: table This is the name of the generic UI component, not the React module! customization: css Design CSS customizability support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

6 participants