Home > Software design >  material ui button custom elevation
material ui button custom elevation

Time:01-06

How can I specify a custom elevation for a MUI Button?

In MUI Button API documentation a disableElevation is documented (which seems to works as an alias of elevation={0}) but I can't find how I can specify an elevation different from the default one.

CodePudding user response:

Keep in mind that contained buttons use different elevation when hovered and when active/focused, so you need to take that into account when you customise them.

@mui/system has a convenient way of applying shadows on elements without the elevation prop, using the sx prop. The syntax is sx={{ boxShadow: 3 }}, which is the same as elevation={3}. The numbers go from 0 to 24.

Codesandbox

  •  Tags:  
  • Related