Currently, I am in the process of developing an application designed for LTR usage, but I am interested in adding RTL support as well. The application itself is built on top of Material UI React. By using CSS Flex Box, I have managed to rotate the application to RTL simply by adding dir="rtl" to the body tag. Additionally, I have also included direction="rtl" in the theme, as outlined here.
Despite these efforts, not all aspects have been successfully changed as expected.
For instance, consider the following example: https://i.sstatic.net/JH1dm.png As you can see in the image, there is padding applied to the left side of the text element. In the RTL version, due to the reversal of elements, the padding left property does not have the intended effect in the UI. Ideally, it should be padding right in order to display the small space between the two elements: https://i.sstatic.net/GpPDz.png
It appears that there may be an error in my implementation, as according to the Material UI documentation here, this feature should work seamlessly after incorporating the provided snippet and wrapping the component around it.
Here is an example of my Parent component, App:
... (code provided in original text) ...
Furthermore, here is an example of one of my components (CLList) mentioned in the previous example:
... (code provided in original text) ...
Lastly, the CSS for CLList is represented by the following code snippet:
... (code provided in original text) ...
In conclusion, I am hopeful that the paddingLeft of the label in the CSS will be automatically adjusted to paddingRight in RTL mode. Is this achievable out of the box, or should I consider utilizing a library such as RTL-CSS-JS to automatically adjust the styles based on the dir attribute of the body tag?
In addition, I am uncertain about which of the two libraries to utilize:
- @material-ui/core/styles
- @material-ui/styles
Could you provide guidance on whether to use the first or second option and clarify the differences between them? Your insights are greatly appreciated.
Thank you for your assistance.
EDIT 1:
After employing rtlCSSJS on my CSS object, I have achieved the desired outcome. However, I am unsure if this is the most optimal approach. The updated CSS for CLList now appears as follows:
... (code provided in original text) ...