It seems that adjusting the margin of each mark by a specific 5px may not be directly possible. The spacing of the marks is determined by the CSS attributes such as position: absolute
and left
. The calculation for this spacing can be found in '\node_modules@material-ui\core\Slider\Slider.js' on line 96:
function valueToPercent(value, min, max) {
return (value - min) * 100 / (max - min);
}
This calculation is then applied to the span on line 885/6:
var percent = valueToPercent(mark.value, min, max);
var style = axisProps[axis].offset(percent);
To accommodate more spacing for a certain number of items, it may be necessary to increase the width of the slider. In the provided demo, this was achieved by changing the width of the sliderDivStyle on line 97/98 from:
width: "100%",
overflow: "hidden",
to:
width: "400%",
// overflow: "hidden",
You can view the demo with the updated result here:
https://codesandbox.io/s/material-demo-forked-lb3rc?file=/demo.tsx