This package is a fork of murtazasultani/tailwind-rtl
.
Tailwind CSS plugin to generate RTL variants.
yarn add @eyewa/tailwind-rtl -D
or
npm install @eyewa/tailwind-rtl --save-dev
RTL styles will be applied when you have lang="ar"
attribute in html
<html lang="ar">
...
...
plugins: [
require('@eyewa/tailwind-rtl')(),
// ...
],
If you want to change when to apply RTL instead of applying based on html:lang(ar)
Eg:
...
<body dir="rtl">
...
plugins: [
require('@eyewa/tailwind-rtl')({selectorPrefix: '[dir="rtl"]'}),
// ...
],
By default the rtl
variant is not enabled to none of the tailwindcss utilities.
To use the rtl
variant add it at the end of any utility you want to use it with.
variants: {
margin: ['responsive', 'rtl'],
padding: ['responsive', 'rtl'],
textAlign: ['responsive', 'rtl']
// ...
},
This plugin generates the following utilities:
/* default prefix */
html:lang(ar) .rtl\:text-2xl {
font-size: 1.5rem;
line-height: 2rem;
}
/* with custom prefix */
[dir='rtl'] .rtl\:text-2xl {
font-size: 1.5rem;
line-height: 2rem;
}
[dir='rtl'] .rtl\:ml-5 {
margin-left: 1.25rem;
}
...
<div class="ml-10 text-xs rtl:text-2xl rtl:ml-5 text-left rtl:text-right md:rtl:text-center">
My App
</div>