0.9.0 • Published 2 years ago

tailwindcss-rtl v0.9.0

Weekly downloads
1,063
License
MIT
Repository
github
Last release
2 years ago

Introduction

Internationalization in semitic languages needs more than just translating texts, you would also need to mirror the layout horizontally. This can be done by adding dir="rtl" the the layout body tag, but this is propably not be enough and you will need to create a different style for RTL.

With tailwindcss-rtl plugin you will be able to support both RTL and LTR in the same style.

Live demo

Full live demo based on the official tailwindcss course project is available here:

Workcation live demo

Workcation-nuxt-i18n-rtl

Usage

Replace all utilities based on Right/Left with the new utilities specified below.

for example when you create an LTR layout and you would like to add left padding to an element you would normaly use pl-6, left is the start direction in LTR so you will replace it with ps-6.

Now add dir="rtl" or dir="ltr" attribute to your top level layout element:

<body dir="rtl">

Note: for all utilities to work as expected adding the dir attribute (both "rtl"/"ltr") to a top level tag is mandatory), even when "ltr" is assumed to be default.

Installation

Install tailwindcss-rtl package:

# Yarn
yarn add tailwindcss-rtl --dev

# NPM
npm install tailwindcss-rtl --save-dev

Require tailwindcss-rtl in the project tailwind.config.js file:

plugins: [
  require('tailwindcss-rtl'),
],

Utilities

*tailwindcss-rtl adds the start and end notations as substitue for left and right.

ClassDescription
ps-Xpadding on start direction
pe-Xpadding on end direction
ms-Xmargin on start direction
me-Xmargin on end direction
text-starttext aligned at the start direction
text-endtext aligned at the end direction
float-startfloat to start direction
float-endfloat to end direction
start-Xplacement of positioned elements on start
end-Xplacement of positioned elements on end
clear-startclear to start direction
clear-endclear to end direction
rounded-s-Xrounded borders on start direction
rounded-e-Xrounded borders on end direction
rounded-ts-Xrounded borders on top start direction
rounded-te-Xrounded borders on top end direction
rounded-bs-Xrounded borders on bottom start direction
rounded-be-Xrounded borders on bottom end direction
border-s-Xborder width on start direction
border-e-Xbordern width on end direction
space-s-Xspace between child
divide-s-Xborder width between child elements