material-ui: [RTL] /* @noflip */ is not working with sx prop

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

input : <Box sx={{ /* @noflip */ direction: 'ltr', }}> ... </Box> Returns a RTL div due to using stylis-plugin-rtl with emotion CacheProvider

Expected behavior 🤔

/* @noflip */ must prevent translating ltr to rtl

Steps to reproduce 🕹

No response

Context 🔦

No response

Your environment 🌎

System: OS: Windows 10 10.0.22000 Binaries: Node: 16.15.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD Browsers: Chrome: Not Found Edge: Spartan (44.22000.120.0), Chromium (103.0.1264.62) npmPackages: @emotion/react: ^11.7.0 => 11.9.3 @emotion/styled: ^11.8.1 => 11.9.3 @mui/base: 5.0.0-alpha.90 @mui/icons-material: ^5.3.0 => 5.8.4 @mui/material: ^5.6.3 => 5.9.1 @mui/private-theming: 5.9.1 @mui/styled-engine: 5.8.7 @mui/system: 5.9.1 @mui/types: 7.1.4 @mui/utils: 5.9.1 @types/react: ^18.0.8 => 18.0.14 react: ^18.1.0 => 18.2.0 react-dom: ^18.1.0 => 18.2.0 typescript: ^4.6.4 => 4.7.4

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

FYI: You can use /* @noflip */ directly in the sx prop if you set it as a part of the value declaration:

For example:

<Typography
  variant="body1"
  sx={{
    textAlign: "left /* @noflip */"
  }}
>
  Force left aligned Text
</Typography>

cc: @ZeeshanTamboli

Thanks for the reproduction.

Looks like it is not possible with the sx prop. We can add it as a feature.

Awesome @scarabaeus . Thanks!

@Vahid-Taheri @maneetgoyal @omerman @sinamoradi1375 Does this work for you? If yes, we can close this issue.

@ZeeshanTamboli

Awesome @scarabaeus . Thanks!

@Vahid-Taheri @maneetgoyal @omerman @sinamoradi1375 Does this work for you? If yes, we can close this issue.

Sorry for the delay 😉 It works well yes.

FYI: You can use /* @noflip */ directly in the sx prop if you set it as a part of the value declaration:

For example:

<Typography
  variant="body1"
  sx={{
    textAlign: "left /* @noflip */"
  }}
>
  Force left aligned Text
</Typography>

cc: @ZeeshanTamboli

very interesting solution. good job bro, that worked for me

I’ll update the MUI RTL Guide with an example if this works out for everyone.

🙄 It is important. can be achieved easily if sx would accept css object like so >

<MyComponent sx={css`
/*! @noflip */
padding-left: 5px;
`}