0.0.7 • Published 4 years ago

tailwind-dir v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Tailwind-dir plugin for Tailwindcss

npm package npm package

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 diffirect style for RTL.

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

A full example can be seen here: workaction-rtl source

This plugin was inspired by Elad Shechter's medium article tackling the same issue with Sass.

Installation

Install `tailwind-dir' package:

# Yarn
yarn add tailwind-dir --dev

# NPM
npm install tailwind-dir --save-dev

Require tailwind-dir in tailwind.config.js file:

plugins: [
  require('tailwind-dir'),
],

Utilities

tailwind-dir adds the start and end notations as substitue for left and right.

Padding

ClassDescriptionLTR PropertyRTL Property
ps-Xpadding on start directionpadding-left: xrempedding-right: xrem
pe-Xpadding on end directionpadding-right: xrempedding-left: xrem

Padding docs

Margin

ClassDescriptionLTR PropertyRTL Property
ms-Xmargin on start directionmargin-left: xremmargin-right: xrem
me-Xmargin on end directionmargin-right: xremmargin-left: xrem

Margin docs

Float

ClassDescriptionLTR PropertyRTL Property
float-startfloat to start directionfloat: leftfloat: right
float-endfloat to end directionfloat: rightfloat: left

Float docs

Right/Left

ClassDescriptionLTR PropertyRTL Property
start-Xfloat to start directionleft: xright: x
end-Xfloat to end directionright: xleft: x

Right/Left docs

Clear

ClassDescriptionLTR PropertyRTL Property
clear-startclear to start directionclear: leftclear: left
clear-endclear to end directionclear: rightclear: right

Clear docs

Usage

Replace all padding, margins, floats and insets utilities with the corresponding utilities.

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

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago