Material-ui: [Box] boxShadow property is not flowing through

Created on 17 Jun 2019  路  7Comments  路  Source: mui-org/material-ui

The boxShadow property of Box is not showing up in HTML.

  • [x] This is not a v0.x issue.
  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior 馃

Here's an example of using the boxShadow property. It should show up as box-shadow property in HTML.

<Box
      height={320}
      bgcolor="#E23838"
      color="#fff"
      boxShadow="inset 0px 4px 4px rgba(0, 0, 0, 0.25)"
      display="flex"
      flexDirection="column"
      justifyContent="center"
      alignItems="center"
    >
      <Typography variant="h1">Hello!</Typography>
</Box>

Current Behavior 馃槸

All other properties show up, but box-shadow does not.

Steps to Reproduce 馃暪

Link: https://codesandbox.io/embed/box-shadow-issue-33o9g

Your Environment 馃寧

| Tech | Version |
|--------------|---------|
| Material-UI | v4.1.1 |
| React | 16.8.6 |
| Browser | Chrome |
| TypeScript | 3.4.5 |
| etc. | |

enhancement good first issue hacktoberfest system

Most helpful comment

Hi, anyone mind if I try this one for hacktoberfest?

All 7 comments

Just looked at the examples. It appears that the boxShadow property is expected to be a number. I was looking at old type definitions that specified it as React.CSSProperties.

Would be nice to have a way to specify as a CSS string property.

@nareshbhatia Correct, this is a feature request, so far, the shadow should be coming from the theme when using an array. Now, I believe we can allow custom values:

diff --git a/packages/material-ui-system/src/style.js b/packages/material-ui-system/src/style.js
index 1724c4e7b..72a007bff 100644
--- a/packages/material-ui-system/src/style.js
+++ b/packages/material-ui-system/src/style.js
@@ -26,7 +26,7 @@ function style(options) {
       if (typeof themeMapping === 'function') {
         value = themeMapping(propValueFinal);
       } else if (Array.isArray(themeMapping)) {
-        value = themeMapping[propValueFinal];
+        value = themeMapping[propValueFinal] || propValueFinal;
       } else {

This would make the behavior consistent between an object theme value and an array one. I'm 馃憤 for it.

On a side note, Bootstrap is removing the iconic jumbotron component https://github.com/twbs/bootstrap/pull/28876. It was probably influenced by Tailwind.
This is something people can reproduce here with:

import React from "react";
import { Box, Typography } from "@material-ui/core";

export default function App() {
  return (
    <Box
      py={{ xs: 6, sm: 10 }}
      bgcolor="primary.main"
      color="primary.contrastText"
      textAlign="center"
    >
      <Typography variant="h1">Hello!</Typography>
    </Box>
  );
}

https://codesandbox.io/s/box-shadow-issue-vfg03

Capture d鈥檈虂cran 2019-06-17 a虁 12 26 26

Hi, anyone mind if I try this one for hacktoberfest?

@flurmbo Please do 馃榿

@joshwooding @oliviertassinari, sorry could anyone explain what's wrong with @rbrishabh's PR for this? It looks like it allows strings to pass through the style function if the themeMapping is an array, similar to the current behavior for if the themeMapping is an object. Thanks

@flurmbo The changes look great, I don't know what happened! I think that adding a test to verify it would be perfect.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tdkn picture tdkn  路  57Comments

Bessonov picture Bessonov  路  93Comments

iceafish picture iceafish  路  62Comments

kybarg picture kybarg  路  164Comments

damianobarbati picture damianobarbati  路  55Comments