I want to add linear-gradient to Material-UI Slider as color. Is it possible? I try everything.
color: \'linear-gradient(180deg, #29ABE2 0%, #00EAA6 100%)\'
linear-gradient
creates an image not a color. So you need to use it in CSS that specifies an image (e.g. background-image
).
Below is an example of a Slider
using a gradient.
import React from "react";
import { makeStyles, withStyles } from "@material-ui/core/styles";
import Slider from "@material-ui/core/Slider";
const useStyles = makeStyles({
root: {
width: 200
}
});
const CustomSlider = withStyles({
rail: {
backgroundImage: "linear-gradient(.25turn, #f00, #00f)"
},
track: {
backgroundImage: "linear-gradient(.25turn, #f00, #00f)"
}
})(Slider);
export default function ContinuousSlider() {
const classes = useStyles();
const [value, setValue] = React.useState(30);
const handleChange = (event, newValue) => {
setValue(newValue);
};
return (
);
}