-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Button] Remove default color, use primary by default #17530
Comments
The reason that the components use grey from the theme, rather than from Perhaps grey isn't the best name (what if you want to turn grey into pink?) but it at least describes the default. |
I understand that you can 'override' the default value, however as 'default' is part of the Enum-type definitions, I thought it might be more useful to instead define it in the palette. |
It is already defined in the palette – |
I see, so you suggest that I remap grey to be the "default", replacing 'default' with 'grey' in the example I gave? |
I'm suggesting that if you want to redefine the color of components that use grey from the theme, you can. |
+1 Im also facing the same issue, @wysird, I love this library, but for instance, I have a simple UI where i want to display a simple button but using theme colors: <Button variant="contained">Button contained</Button> In order to it would be nice to have something like : const theme = createMuiTheme({
palette: {
default: {
main: blue[500],
light: blue[500],
dark: blue[500],
contrastText: "#ffffff",
},
},
}); But instead we have to do this: <Button variant="contained" color="primary">Button contained primary</Button> const theme = createMuiTheme({
palette: {
primary: {
main: blue[500],
light: blue[500],
dark: blue[500],
contrastText: "#ffffff",
},
},
}); And finally if you want to override the default button you would need to override with: {
overrides: {
MuiButton:{
contained:{
//...do override of colors and background here.
}
}
}
} |
@mbrookes how did you workaround this? |
@CoericK I do totally agree though, I feel like overriding the MuiButtons (and everything else) is not really right, given that you refer to For this reason, it would still make sense to match palette: {
default: {
main: blue[500],
light: blue[500],
dark: blue[500],
contrastText: '#ffffff',
},
}, Either that, or if (as I suggested) the name provided to color changes from palette: {
grey: {
main: blue[500],
light: blue[500],
dark: blue[500],
contrastText: "#ffffff",
},
}, Thoughts, @mbrookes? |
What about we drop this diff --git a/packages/material-ui/src/Button/Button.js b/packages/material-ui/src/Button/Button.js
index 7a780777a..bf1c7c19c 100644
--- a/packages/material-ui/src/Button/Button.js
+++ b/packages/material-ui/src/Button/Button.js
@@ -264,7 +264,7 @@ const Button = React.forwardRef(function Button(props, ref) {
children,
classes,
className,
- color = 'default',
+ color = 'primary',
component = 'button',
disabled = false,
disableElevation = false,
@@ -346,7 +346,7 @@ Button.propTypes = {
/**
* The color of the component. It supports those theme colors that make sense for this component.
*/
- color: PropTypes.oneOf(['default', 'inherit', 'primary', 'secondary']),
+ color: PropTypes.oneOf(['inherit', 'primary', 'secondary']),
/**
* The component used for the root node.
* Either a string to use a HTML element or a component. Pros:
|
I think inheriting from above is probably a better idea; the real problem is when trying to style the colours to work with your new backgrounds and the default just doesn't change; it sticks with whatever it has. I'm totally behind just removing the default as a compromise to needing to override it. |
Actually as an extension to what you suggested @oliviertassinari, it might be worth changing all 'root' styles (e.g. |
@wysird I fear the full support of |
Sorry, I don't mean to use
etc. I'm suggesting that the default for all these is 'inherit', meaning there should not really be any reason to override, and Does this make sense, or am I muddying the water? |
@wysird The color CSS property inherits by default. We override it, sometimes, to use the values from the theme; it doesn't seem there is any change required here; |
Oh yeah, my bad, I see what you mean. |
It'd be useful to be able to override the 'default' palette value and it actually take effect.
e.g.
At the moment some components (like
Button
) use specific colours (liketheme.palette.grey[300]
) instead oftheme.palette.default
. Switching this round would allow us to make use of the default them in the palette.e.g.
The text was updated successfully, but these errors were encountered: