garronej/tss-react

How to opt out of RTL transformation?

malouro opened this issue · 3 comments

We're trying to implement support for right-to-left styles in one of our libraries that utilizes tss-react. I was expecting to possibly be able to use flip: false, as showcased in the MUI guide for RTL, within the relevant withStyles and makeStyles usages we have, but I don't believe this is supported in tss-react.

Does there exist a method by which we can opt out of RTL transformation currently, and we're just not using it properly, or is this a potential new feature that could be implemented?

Thanks!

I'm sorry I've nothing to offer regarding LTR at the moment but I'm more than willing to work on it if you suggest an API proposal to support it.

So I was able to work out a solution that works for me currently. Probably should've tried this before, but the inline comment syntax mentioned in the MUI RTL guide does in fact work.

For example, in a withStyles style property:

withStyles(
  Component,
  (theme) => ({
    root: {
      // Won't flip to "textAlign: 'right'" in RTL:
      textAlign: 'left /* @noflip */'
    }
  })
);

This is satisfactory for my needs, so feel free to close out unless you feel strongly about supporting some other alternative API :)

Thanks a lof for your valuable feedback!