Simple way to Convert any stylesheet to RTL version
npm install rtl-converter
Many manual converted RTL frameworks have been used and proved not to be quite flawless, for example, I couldn't find any Bootstrap RTL version that displays radio buttons correctly. This project tries to make the process flawless and automatic.
Given the following stylesheet
.class { margin-left: 10px; text-align: left; background-color: #fff; }
This will output
.class { background-color: #fff; } .rtl .class { margin-right: 10px; } .ltr .class { margin-left: 10px; }
const rtlConverter = require('rtl-converter'); let RTLCss = rtlConverter(strCss);
to add RTL support, add class="rtl" to html tag,add direction set to rtl, for ltr you have to the the opposite.
RTL
... <style> html {direction: rtl} </style> </head> <html class="rtl"> ...
LTR
... <style> html {direction: ltr} </style> </head> <html class="ltr"> ...