Skip to content

Latest commit

 

History

History
71 lines (51 loc) · 1.05 KB

README.md

File metadata and controls

71 lines (51 loc) · 1.05 KB

RTL Converter

Simple way to Convert any stylesheet to RTL version

Installation

npm install rtl-converter

Motivation

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.

Output

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;
}

Usage

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">
...