-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
Allow using linear-gradient color in theme palette #35159
Comments
I see that the docs are lacking this info. We should mention that the @vimutti77 to make the background works, you need to use |
@siriwatknp If the channel color is an issue, Can I just specify it, so it does not need to be calculated at runtime? However, my current approach is to use a different key https://codesandbox.io/s/suspicious-haze-svgxrp But I need to make sure that when a new version of |
@vimutti77 Looks like you are trying to create a custom palette. Here is my suggestion:
|
Experimental_CssVarsProvider and experimental_extendTheme didn't work for me who is using ReactJs. import { createTheme , Box, Typography, Button, ThemeProvider } from "@mui/material";
const theme = createTheme({
palette: {
gradient: {
main: "linear-gradient(-39deg, #4991f8 0%, #4bc1ff 100%)",
mainChannel: "0 0 0",
light: "linear-gradient(135deg, #4aaffd 0%, #4992f8 100%)",
lightChannel: "0 0 0",
dark: "linear-gradient(135deg, #4cc2ff 0%, #4aa0fa 100%)",
darkChannel: "0 0 0",
contrastText: "#fff",
contrastTextChannel: "0 0 0"
}
}
});
const Rewards = () => {
return (
<ThemeProvider theme={theme}>
<Box sx={{ width: "80%" }}>
<Button
sx={{ background: (theme) => theme.palette.gradient.main }}
variant="determinate"
value={progress}
/>
</Box>
</ThemeProvider>
)
export default Rewards; |
Could you share a CodeSandbox to me so that I can take a look the error? |
My bad, it is working. I was directly giving the color to the background rather than using sx. It does work. |
Hello all, i want to use gradient in my icon material ? is it possible ? |
Duplicates
Latest version
Summary 💡
Allow using linear-gradient color in theme palette or allow to use it if it is non-default palette
Examples 🌈
I try to use linear-gradient in palette, but I got
MUI: Unsupported 'linear-gradient(-39deg, #4991f8 0%, #4bc1ff 100%)' color.
https://codesandbox.io/s/determined-fermat-mikfcs?file=/src/App.tsx
Motivation 🔦
My client wants to use linear-gradient as one of background of button.
The text was updated successfully, but these errors were encountered: